Class PdfColumn
Represents a single column of the table.
Inheritance
System.Object
PdfColumn
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Syncfusion.Pdf.Tables
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfColumn
Examples
// Create a PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
//create the PdfLightTable
PdfLightTable table = new PdfLightTable();
// Set the DataSourceType as Direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect;
// Get the columns collection
PdfColumnCollection tableColumns = table.Columns;
// Add Columns
tableColumns.Add(new PdfColumn("Roll Number"));
tableColumns.Add(new PdfColumn("Name"));
tableColumns.Add(new PdfColumn("Class"));
// Add Rows
table.Rows.Add(new object[] { "111", "Maxim", "III" });
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
' Create a PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
'create the PdfLightTable
Dim table As New PdfLightTable()
' Set the DataSourceType as Direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect
' Get the columns collection
Dim tableColumns As PdfColumnCollection = table.Columns
' Add Columns
tableColumns.Add(New PdfColumn("Roll Number"))
tableColumns.Add(New PdfColumn("Name"))
tableColumns.Add(New PdfColumn("Class"))
' Add Rows
table.Rows.Add(New Object() { "111", "Maxim", "III" })
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)
Constructors
PdfColumn()
Initializes a new instance of the PdfColumn class.
Declaration
public PdfColumn()
Examples
// Create a PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
PdfLightTable table = new PdfLightTable();
// Set the DataSourceType as Direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect;
// Get the columns collection
PdfColumnCollection tableColumns = table.Columns;
// Creating Columns
tableColumns.Add(new PdfColumn("Name"));
tableColumns.Add(new PdfColumn("Class"));
// Create a new column
PdfColumn rollNumber = new PdfColumn();
//Set the string format
rollNumber.StringFormat = new PdfStringFormat(PdfTextAlignment.Left);
//set the column name
rollNumber.ColumnName = "Roll Number";
//Add the column
tableColumns.Add(rollNumber);
// Adding Rows
table.Rows.Add(new object[] { "111", "Maxim", "III" });
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
' Create a PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
Dim table As New PdfLightTable()
' Set the DataSourceType as Direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect
' Get the columns collection
Dim tableColumns As PdfColumnCollection = table.Columns
' Creating Columns
tableColumns.Add(New PdfColumn("Name"))
tableColumns.Add(New PdfColumn("Class"))
' Create a new column
Dim rollNumber As New PdfColumn()
'Set the string format
rollNumber.StringFormat = New PdfStringFormat(PdfTextAlignment.Left)
'set the column name
rollNumber.ColumnName = "Roll Number"
'Add the column
tableColumns.Add(rollNumber)
' Adding Rows
table.Rows.Add(New Object() { "111", "Maxim", "III" })
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)
PdfColumn(String)
Initializes a new instance of the PdfColumn class with specified column name.
Declaration
public PdfColumn(string columnName)
Parameters
Type | Name | Description |
---|---|---|
System.String | columnName | The name of the column. |
Examples
// Create a PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
PdfLightTable table = new PdfLightTable();
// Set the DataSourceType as Direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect;
// Get the columns collection
PdfColumnCollection tableColumns = table.Columns;
// Creating Columns
tableColumns.Add(new PdfColumn("Name"));
tableColumns.Add(new PdfColumn("Class"));
// Create a new column
PdfColumn rollNumber = new PdfColumn();
//Set the string format
rollNumber.StringFormat = new PdfStringFormat(PdfTextAlignment.Left);
//set the column name
rollNumber.ColumnName = "Roll Number";
//Add the column
tableColumns.Add(rollNumber);
// Adding Rows
table.Rows.Add(new object[] { "111", "Maxim", "III" });
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
' Create a PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
Dim table As New PdfLightTable()
' Set the DataSourceType as Direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect
' Get the columns collection
Dim tableColumns As PdfColumnCollection = table.Columns
' Creating Columns
tableColumns.Add(New PdfColumn("Name"))
tableColumns.Add(New PdfColumn("Class"))
' Create a new column
Dim rollNumber As New PdfColumn()
'Set the string format
rollNumber.StringFormat = New PdfStringFormat(PdfTextAlignment.Left)
'set the column name
rollNumber.ColumnName = "Roll Number"
'Add the column
tableColumns.Add(rollNumber)
' Adding Rows
table.Rows.Add(New Object() { "111", "Maxim", "III" })
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)
Properties
ColumnName
Gets or sets name of the column.
Declaration
public string ColumnName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Examples
// Create a PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
PdfLightTable table = new PdfLightTable();
// Set the DataSourceType as Direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect;
// Get the columns collection
PdfColumnCollection tableColumns = table.Columns;
// Creating Columns
tableColumns.Add(new PdfColumn("Name"));
tableColumns.Add(new PdfColumn("Class"));
// Create a new column
PdfColumn rollNumber = new PdfColumn();
//Set the string format
rollNumber.StringFormat = new PdfStringFormat(PdfTextAlignment.Left);
//set the column name
rollNumber.ColumnName = "Roll Number";
//Add the column
tableColumns.Add(rollNumber);
// Adding Rows
table.Rows.Add(new object[] { "111", "Maxim", "III" });
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
' Create a PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
Dim table As New PdfLightTable()
' Set the DataSourceType as Direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect
' Get the columns collection
Dim tableColumns As PdfColumnCollection = table.Columns
' Creating Columns
tableColumns.Add(New PdfColumn("Name"))
tableColumns.Add(New PdfColumn("Class"))
' Create a new column
Dim rollNumber As New PdfColumn()
'Set the string format
rollNumber.StringFormat = New PdfStringFormat(PdfTextAlignment.Left)
'set the column name
rollNumber.ColumnName = "Roll Number"
'Add the column
tableColumns.Add(rollNumber)
' Adding Rows
table.Rows.Add(New Object() { "111", "Maxim", "III" })
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)
StringFormat
Gets or sets the string format of the column text
Declaration
public PdfStringFormat StringFormat { get; set; }
Property Value
Type | Description |
---|---|
PdfStringFormat | The format of the cell text. |
Examples
// Create a PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
PdfLightTable table = new PdfLightTable();
// Set the DataSourceType as Direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect;
// Get the columns collection
PdfColumnCollection tableColumns = table.Columns;
// Creating Columns
tableColumns.Add(new PdfColumn("Name"));
tableColumns.Add(new PdfColumn("Class"));
// Create a new column
PdfColumn rollNumber = new PdfColumn("Roll Number");
//Set the string format
rollNumber.StringFormat = new PdfStringFormat(PdfTextAlignment.Right);
//Add the column
tableColumns.Add(rollNumber);
// Adding Rows
table.Rows.Add(new object[] { "111", "Maxim", "III" });
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
' Create a PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
Dim table As New PdfLightTable()
' Set the DataSourceType as Direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect
' Get the columns collection
Dim tableColumns As PdfColumnCollection = table.Columns
' Creating Columns
tableColumns.Add(New PdfColumn("Name"))
tableColumns.Add(New PdfColumn("Class"))
' Create a new column
Dim rollNumber As New PdfColumn("Roll Number")
'Set the string format
rollNumber.StringFormat = New PdfStringFormat(PdfTextAlignment.Right)
'Add the column
tableColumns.Add(rollNumber)
' Adding Rows
table.Rows.Add(New Object() { "111", "Maxim", "III" })
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)
Width
Gets or sets the width of the column.
Declaration
public float Width { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Examples
// Create a PDF document
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
PdfLightTable table = new PdfLightTable();
// Set the DataSourceType as Direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect;
// Get the columns collection
PdfColumnCollection tableColumns = table.Columns;
// Creating Columns
tableColumns.Add(new PdfColumn("Name"));
tableColumns.Add(new PdfColumn("Class"));
// Create a new column
PdfColumn rollNumber = new PdfColumn("Roll Number");
//Set the string format
rollNumber.StringFormat = new PdfStringFormat(PdfTextAlignment.Left);
//set the width
rollNumber.Width = 20;
//Add the column
tableColumns.Add(rollNumber);
// Adding Rows
table.Rows.Add(new object[] { "111", "Maxim", "III" });
// Draw the table
table.Draw(page, new PointF(0, 0));
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
' Create a PDF document
Dim document As New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
Dim table As New PdfLightTable()
' Set the DataSourceType as Direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect
' Get the columns collection
Dim tableColumns As PdfColumnCollection = table.Columns
' Creating Columns
tableColumns.Add(New PdfColumn("Name"))
tableColumns.Add(New PdfColumn("Class"))
' Create a new column
Dim rollNumber As New PdfColumn("Roll Number")
'Set the string format
rollNumber.StringFormat = New PdfStringFormat(PdfTextAlignment.Left)
'set the width
rollNumber.Width = 20
'Add the column
tableColumns.Add(rollNumber)
' Adding Rows
table.Rows.Add(New Object() { "111", "Maxim", "III" })
' Draw the table
table.Draw(page, New PointF(0, 0))
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)