Class PdfLightTable
- Namespace
- Syncfusion.Pdf.Tables
- Assembly
- Syncfusion.Pdf.Portable.dll
Create table by entering the data manually or from an external data source.
public class PdfLightTable : PdfLayoutElement
- Inheritance
-
PdfLightTable
- Inherited Members
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
// Add a page.
PdfPage page = document.Pages.Add();
//Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
//Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the DataTable.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the DataTable.
table.Rows.Add(new string[] { "abc", "21", "Male" });
// Assign data source.
pdfLightTable.DataSource = table;
// Draw PdfLightTable.
pdfLightTable.Draw(page, new PointF(0, 0));
// Save the document.
document.Save("output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the DataTable.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the DataTable.
table.Rows.Add(New String() {"abc", "21", "Male"})
'Assign data source.
pdfLightTable.DataSource = table
'Draw PdfLightTable.
pdfLightTable.Draw(page, New PointF(0, 0))
'Save the document.
document.Save("output.pdf")
'Close the document
document.Close(True)
Constructors
PdfLightTable()
public PdfLightTable()
Properties
AllowRowBreakAcrossPages
Gets a value indicating the row break is to be made or not.
public bool AllowRowBreakAcrossPages { get; set; }
Property Value
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a new PDF light table instance.
PdfLightTable table = new PdfLightTable();
//Create a DataTable.
DataTable dataTable = new DataTable();
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
dataTable.Rows.Add(new object[] { "E03", "George" });
dataTable.Rows.Add(new object[] { "E04", "Stefan" });
dataTable.Rows.Add(new object[] { "E05", "Mathew" });
//Assign data source.
table.DataSource = dataTable;
//Set row break.
table.AllowRowBreakAcrossPages = true;
//Apply built-in table style
table.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.GridTable1Light);
//Draw light table to the page of PDF document.
table.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a new PDF light table instance.
Dim table As New PdfLightTable()
'Create a DataTable.
Dim dataTable As New DataTable()
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
dataTable.Rows.Add(New Object() { "E03", "George"})
dataTable.Rows.Add(New Object() { "E04", "Stefan"})
dataTable.Rows.Add(New Object() { "E05", "Mathew"})
'Assign data source.
table.DataSource = dataTable
'Set row break.
table.AllowRowBreakAcrossPages = True
'Apply built-in table style
table.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.GridTable1Light)
'Draw light table to the page of PDF document.
table.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
ColumnProportionalSizing
Gets or sets the value to distribute the available table width by weighted proportions of table columns.
public bool ColumnProportionalSizing { get; set; }
Property Value
- bool
Boolean
Columns
Gets the collection of columns contained in the table.Read-Only.
public PdfColumnCollection Columns { get; }
Property Value
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;
// Creating Columns
tableColumns.Add(new PdfColumn("Roll Number"));
tableColumns.Add(new PdfColumn("Name"));
tableColumns.Add(new PdfColumn("Class"));
// Get the row collection
PdfRowCollection rows = table.Rows;
// Adding Rows
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 PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
'Create the PdfLightTable
Dim table As PdfLightTable = 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("Roll Number"))
tableColumns.Add(New PdfColumn("Name"))
tableColumns.Add(New PdfColumn("Class"))
'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)
- See Also
DataSource
Gets or sets the data source to bind into PdfLightTable.
public object DataSource { get; set; }
Property Value
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Create DataTable for source
DataTable dataTable = new DataTable("Table");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
//Create a new page
PdfPage page = document.Pages.Add();
//Create the PdfLightTable
PdfLightTable table = new PdfLightTable();
//set the data source
table.DataSource = dataTable;
//Draw the table
table.Draw(page.Graphics);
//save the document
document.Save("Output.pdf");
//Close the document.
document.Close(true);
// Create a new document
PdfDocument document = new PdfDocument();
//Create DataTable for source
DataTable dataTable = new DataTable("Table");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
//Create a new page
PdfPage page = document.Pages.Add();
//Create the PdfLightTable
PdfLightTable table = new PdfLightTable();
//set the data source
table.DataSource = dataTable;
//Draw the table
table.Draw(page.Graphics);
//save the document
document.Save("Output.pdf");
//Close the document.
document.Close(true);
- See Also
DataSourceType
Gets or sets the data source type of the PdfLightTable.
public PdfLightTableDataSourceType DataSourceType { get; set; }
Property Value
Examples
// Create a new document
PdfDocument document = new PdfDocument();
//Create DataTable for source
DataTable dataTable = new DataTable("Table");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
//Create a new page
PdfPage page = document.Pages.Add();
//Create the PdfLightTable
PdfLightTable table = new PdfLightTable();
//Set the data source type
table.DataSourceType = PdfLightTableDataSourceType.TableDirect;
//Set the data table
table.DataSource = dataTable;
Draw the table
table.Draw(page.Graphics);
//Save the document
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new document
Dim document As PdfDocument = New PdfDocument()
'Create DataTable for source
Dim dataTable As DataTable = New DataTable("Table")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = New Object() {"Table Features Demo", ""}
dataTable.Rows.Add(values)
'Create a page
Dim page As PdfPage = document.Pages.Add()
'Create the PdfLightTable
Dim table As PdfLightTable = New PdfLightTable()
'Set the data source type
table.DataSourceType = PdfLightTableDataSourceType.TableDirect
'Set the data source
table.DataSource = dataTable
' Draw the table
table.Draw(page.Graphics)
'Save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)
- See Also
Rows
Gets the collection of rows contained in the table.Read-Only.
public PdfRowCollection Rows { get; }
Property Value
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("Roll Number"));
tableColumns.Add(new PdfColumn("Name"));
tableColumns.Add(new PdfColumn("Class"));
// Get the row collection
PdfRowCollection rows = table.Rows;
// Adding Rows
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 PdfDocument = New PdfDocument()
' Create a page
Dim page As PdfPage = document.Pages.Add()
Dim table As PdfLightTable = 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("Roll Number"))
tableColumns.Add(New PdfColumn("Name"))
tableColumns.Add(New PdfColumn("Class"))
' Get the row collection
Dim rows As PdfRowCollection = table.Rows
' Adding Rows
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)
- See Also
Style
Gets or sets the style properties in PdfLightTable.
public PdfLightTableStyle Style { get; set; }
Property Value
Examples
//Create a new document
PdfDocument document = new PdfDocument();
//Create DataTable for source
DataTable dataTable = new DataTable("myTable");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Table Features Demo", "" };
dataTable.Rows.Add(values);
//Create the page
PdfPage page = document.Pages.Add();
//Create the PdfLightTable
PdfLightTable table = new PdfLightTable();
//Create the font
PdfFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 12);
// Alternative cell style
PdfCellStyle altStyle = new PdfCellStyle(font, PdfBrushes.White, PdfPens.Green);
altStyle.BackgroundBrush = PdfBrushes.DarkGray;
// Table header cell style
PdfCellStyle headerStyle = new PdfCellStyle(font, PdfBrushes.White, PdfPens.Brown);
headerStyle.BackgroundBrush = PdfBrushes.Red;
//Set the table style
table.Style.AlternateStyle = altStyle;
table.Style.HeaderStyle = headerStyle;
//set the data source
table.DataSource = dataTable;
// Draw the table
table.Draw(page.Graphics);
//save the document
document.Save("output.pdf");
//Close the document
document.Close(true);
'Create a new document
Dim document As PdfDocument = New PdfDocument()
'Create DataTable for source
Dim dataTable As DataTable = New DataTable("myTable")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = New Object() {"Table Features Demo", ""}
dataTable.Rows.Add(values)
'Create the page
Dim page As PdfPage = document.Pages.Add()
'Create the PdfLightTable
Dim table As PdfLightTable = New PdfLightTable()
'Create the font
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.TimesRoman, 12)
'Alternative cell style
Dim altStyle As PdfCellStyle = New PdfCellStyle(font, PdfBrushes.White, PdfPens.Green)
altStyle.BackgroundBrush = PdfBrushes.DarkGray
'Table header cell style
Dim headerStyle As PdfCellStyle = New PdfCellStyle(font, PdfBrushes.White, PdfPens.Brown)
headerStyle.BackgroundBrush = PdfBrushes.Red
'Set the table style
table.Style.AlternateStyle = altStyle
table.Style.HeaderStyle = headerStyle
'set the data source
table.DataSource = dataTable
'Draw the table
table.Draw(page.Graphics)
'save the document
document.Save("Output.pdf")
'Close the document
document.Close(True)
- See Also
Methods
ApplyBuiltinStyle(PdfLightTableBuiltinStyle)
Apply built-in table style to the table
public void ApplyBuiltinStyle(PdfLightTableBuiltinStyle tableStyle)
Parameters
tableStyle
PdfLightTableBuiltinStyleenum of PdfLightTableBuiltinStyle
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a new PDF light table instance.
PdfLightTable table = new PdfLightTable();
//Create a DataTable.
DataTable dataTable = new DataTable();
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
dataTable.Rows.Add(new object[] { "E03", "George" });
dataTable.Rows.Add(new object[] { "E04", "Stefan" });
dataTable.Rows.Add(new object[] { "E05", "Mathew" });
//Assign data source.
table.DataSource = dataTable;
//Apply built-in table style
table.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.ListTable6ColorfulAccent4);
//Draw table to the page of PDF document.
table.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a new PDF light table instance.
Dim table As New PdfLightTable()
'Create a DataTable.
Dim dataTable As New DataTable()
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
dataTable.Rows.Add(New Object() { "E03", "George"})
dataTable.Rows.Add(New Object() { "E04", "Stefan"})
dataTable.Rows.Add(New Object() { "E05", "Mathew"})
'Assign data source.
table.DataSource = dataTable
'Apply built-in table style
table.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.ListTable6ColorfulAccent4)
'Draw table to the page of PDF document.
table.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
ApplyBuiltinStyle(PdfLightTableBuiltinStyle, PdfLightTableBuiltinStyleSettings)
Apply built-in table style to the table
public void ApplyBuiltinStyle(PdfLightTableBuiltinStyle lightTableStyle, PdfLightTableBuiltinStyleSettings lightTableSetting)
Parameters
lightTableStyle
PdfLightTableBuiltinStyleenum of PdfLightTableBuiltinStyle
lightTableSetting
PdfLightTableBuiltinStyleSettingsThe PdfLightTableBuiltinStyleSettings
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a new PDF light table instance.
PdfLightTable table = new PdfLightTable();
//Create a DataTable.
DataTable dataTable = new DataTable();
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
dataTable.Rows.Add(new object[] { "E03", "George" });
dataTable.Rows.Add(new object[] { "E04", "Stefan" });
dataTable.Rows.Add(new object[] { "E05", "Mathew" });
//Assign data source.
table.DataSource = dataTable;
//Create PDF light table build style settings instance.
dfLightTableBuiltinStyleSettings settings = new PdfLightTableBuiltinStyleSettings();
settings.ApplyStyleForBandedColumns = true;
settings.ApplyStyleForBandedRows = true;
settings.ApplyStyleForFirstColumn = true;
settings.ApplyStyleForHeaderRow = true;
settings.ApplyStyleForLastColumn = true;
settings.ApplyStyleForLastRow = true;
//Apply built-in table style
table.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.ListTable6ColorfulAccent4, settings);
//Draw table to the page of PDF document.
table.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a new PDF light table instance.
Dim table As New PdfLightTable()
'Create a DataTable.
Dim dataTable As New DataTable()
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() { "E01", "Clay"})
dataTable.Rows.Add(New Object() { "E02", "Thomas"})
dataTable.Rows.Add(New Object() { "E03", "George"})
dataTable.Rows.Add(New Object() { "E04", "Stefan"})
dataTable.Rows.Add(New Object() { "E05", "Mathew"})
'Assign data source.
table.DataSource = dataTable
'Create PDF light table build style settings instance.
Dim settings As New PdfLightTableBuiltinStyleSettings()
settings.ApplyStyleForBandedColumns = True
settings.ApplyStyleForBandedRows = True
settings.ApplyStyleForFirstColumn = True
settings.ApplyStyleForHeaderRow = True
settings.ApplyStyleForLastColumn = True
settings.ApplyStyleForLastRow = True
'Apply built-in table style
table.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.ListTable6ColorfulAccent4, settings)
'Draw table to the page of PDF document.
table.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Draw(PdfGraphics, PointF, float)
Draw the PdfLightTable in the specified PdfGraphics with specified graphics ,location and width.
public void Draw(PdfGraphics graphics, PointF location, float width)
Parameters
graphics
PdfGraphicsGraphics context where the element should be printed.
location
PointFThe location of the element.
width
floatThe width of the table.
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
// Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the DataTable.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the DataTable.
table.Rows.Add(new string[] { "abc", "21", "Male" });
//Assign data source.
pdfLightTable.DataSource = table;
//Draw PdfLightTable.
pdfLightTable.Draw(page.Graphics, new PointF(0, 0),500);
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the DataTable.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the DataTable.
table.Rows.Add(New String() { "abc", "21", "Male" })
'Assign data source.
pdfLightTable.DataSource = table
'Draw PdfLightTable.
pdfLightTable.Draw(page.Graphics, New PointF(0, 0),500)
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Draw(PdfGraphics, RectangleF)
public void Draw(PdfGraphics graphics, RectangleF bounds)
Parameters
graphics
PdfGraphicsGraphics context where the element should be drawn.
bounds
RectangleFThe bounds of the table should be drawn.
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
// Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the DataTable.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the DataTable.
table.Rows.Add(new string[] { "abc", "21", "Male" });
//Assign data source.
pdfLightTable.DataSource = table;
//Draw PdfLightTable.
pdfLightTable.Draw(page.Graphics, new RectangleF(0, 0,500,500));
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the DataTable.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the DataTable.
table.Rows.Add(New String() { "abc", "21", "Male" })
'Assign data source.
pdfLightTable.DataSource = table
'Draw PdfLightTable.
pdfLightTable.Draw(page.Graphics, New RectangleF(0, 0,500,500))
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Draw(PdfGraphics, float, float)
Draw the PdfLightTable in the specified PdfGraphics and x,y coordinates.
public override void Draw(PdfGraphics graphics, float x, float y)
Parameters
graphics
PdfGraphicsGraphics context where the element should be printed.
x
floatThe x co-ordinate of the element.
y
floatThe y co-ordinate of the element.
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
// Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the Data Table.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the Data Table.//you can add multiple rows
table.Rows.Add(new string[] { "abc", "21", "Male" });
//Assign data source.
pdfLightTable.DataSource = table;
//Draw PdfLightTable.
pdfLightTable.Draw(page.Graphics, 10, 10);
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the Data Table.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the Data Table.//you can add multiple rows
table.Rows.Add(New String() { "abc", "21", "Male" })
'Assign data source.
pdfLightTable.DataSource = table
'Draw PdfLightTable.
pdfLightTable.Draw(page.Graphics, 10, 10)
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Draw(PdfGraphics, float, float, float)
Draw the PdfLightTable with the specified PdfGraphics,x and y coordinates and width.
public void Draw(PdfGraphics graphics, float x, float y, float width)
Parameters
graphics
PdfGraphicsGraphics context where the element should be drawn.
x
floatThe x co-ordinate of the element.
y
floatThe y co-ordinate of the element.
width
floatThe width of the table.
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
// Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the DataTable.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the DataTable.
table.Rows.Add(new string[] { "abc", "21", "Male" });
//Assign data source.
pdfLightTable.DataSource = table;
//Draw PdfLightTable.
pdfLightTable.Draw(page.Graphics, 10, 10, 500);
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the DataTable.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the DataTable.
table.Rows.Add(New String() { "abc", "21", "Male" })
'Assign data source.
pdfLightTable.DataSource = table
'Draw PdfLightTable.
pdfLightTable.Draw(page.Graphics, 10, 10, 500)
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Draw(PdfPage, PointF)
Draw the PdfLightTable in the specified PdfPage and location.
public PdfLightTableLayoutResult Draw(PdfPage page, PointF location)
Parameters
page
PdfPageThe page of the table should be drawn.
location
PointFThe x,y coordinates of the table.
Returns
- PdfLightTableLayoutResult
The PdfLightTable layout result
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
// Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the DataTable.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the DataTable.
table.Rows.Add(new string[] { "abc", "21", "Male" });
//Assign data source.
pdfLightTable.DataSource = table;
//Draw PdfLightTable.
pdfLightTable.Draw(page, new PointF(0, 0));
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the DataTable.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the DataTable.
table.Rows.Add(New String() { "abc", "21", "Male" })
'Assign data source.
pdfLightTable.DataSource = table
'Draw PdfLightTable.
pdfLightTable.Draw(page, New PointF(0, 0))
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Draw(PdfPage, PointF, PdfLightTableLayoutFormat)
Draw the PdfLightTable in the specified PdfPage,location and PdfLightTableLayoutFormat.
public PdfLightTableLayoutResult Draw(PdfPage page, PointF location, PdfLightTableLayoutFormat format)
Parameters
page
PdfPageThe page of the table should be drawn.
location
PointFThe x,y coordinates of the table.
format
PdfLightTableLayoutFormatThe PdfLightTable layout format.
Returns
- PdfLightTableLayoutResult
The PdfLightTable layout result.
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
// Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the Data Table.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the Data Table.//you can add multiple rows
table.Rows.Add(new string[] { "abc", "21", "Male" });
//Assign data source.
pdfLightTable.DataSource = table;
//Set properties to paginate the table.
PdfLightTableLayoutFormat layoutFormat = new PdfLightTableLayoutFormat();
layoutFormat.Break = PdfLayoutBreakType.FitPage;
layoutFormat.Layout = PdfLayoutType.Paginate;
//Draw PdfLightTable.
pdfLightTable.Draw(page, new PointF(0, 0), layoutFormat);
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the Data Table.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the Data Table.//you can add multiple rows
table.Rows.Add(New String() { "abc", "21", "Male" })
'Assign data source.
pdfLightTable.DataSource = table
'Set properties to paginate the table.
Dim layoutFormat As New PdfLightTableLayoutFormat()
layoutFormat.Break = PdfLayoutBreakType.FitPage
layoutFormat.Layout = PdfLayoutType.Paginate
'Draw PdfLightTable.
pdfLightTable.Draw(page, New PointF(0, 0), layoutFormat)
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Draw(PdfPage, RectangleF)
Draw the PdfLightTable in the specified PdfPage and bounds.
public PdfLightTableLayoutResult Draw(PdfPage page, RectangleF bounds)
Parameters
page
PdfPageThe page of the table should be drawn.
bounds
RectangleFThe bounds of the table.
Returns
- PdfLightTableLayoutResult
The PdfLightTable layout result
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
// Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the DataTable.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the DataTable.
table.Rows.Add(new string[] { "abc", "21", "Male" });
//Assign data source.
pdfLightTable.DataSource = table;
//Draw PdfLightTable.
pdfLightTable.Draw(page, new RectangleF(0,0,500,500));
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the DataTable.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the DataTable.
table.Rows.Add(New String() { "abc", "21", "Male" })
'Assign data source.
pdfLightTable.DataSource = table
'Draw PdfLightTable.
pdfLightTable.Draw(page, New RectangleF(0,0,500,500))
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Draw(PdfPage, RectangleF, PdfLightTableLayoutFormat)
Draw the PdfLightTable in the specified PdfPage,bounds and layout format.
public PdfLightTableLayoutResult Draw(PdfPage page, RectangleF bounds, PdfLightTableLayoutFormat format)
Parameters
page
PdfPageThe page of the table should be drawn.
bounds
RectangleFThe bounds of the table.
format
PdfLightTableLayoutFormatThe PdfLightTable layout format.
Returns
- PdfLightTableLayoutResult
The PdfLightTable layout result
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
// Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the Data Table.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the Data Table.//you can add multiple rows
table.Rows.Add(new string[] { "abc", "21", "Male" });
//Assign data source.
pdfLightTable.DataSource = table;
//Set properties to paginate the table.
PdfLightTableLayoutFormat layoutFormat = new PdfLightTableLayoutFormat();
layoutFormat.Break = PdfLayoutBreakType.FitPage;
layoutFormat.Layout = PdfLayoutType.Paginate;
//Draw PdfLightTable.
pdfLightTable.Draw(page, new RectangleF(0, 0,500,500), layoutFormat);
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the Data Table.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the Data Table.//you can add multiple rows
table.Rows.Add(New String() { "abc", "21", "Male" })
'Assign data source.
pdfLightTable.DataSource = table
'Set properties to paginate the table.
Dim layoutFormat As New PdfLightTableLayoutFormat()
layoutFormat.Break = PdfLayoutBreakType.FitPage
layoutFormat.Layout = PdfLayoutType.Paginate
'Draw PdfLightTable.
pdfLightTable.Draw(page, New RectangleF(0, 0,500,500), layoutFormat)
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Draw(PdfPage, float, float)
Draw the PdfLightTable in the specified PdfPage and x, y coordinates.
public PdfLightTableLayoutResult Draw(PdfPage page, float x, float y)
Parameters
page
PdfPageThe page of the table should be drawn.
x
floatThe X co-ordinate of the element.
y
floatThe y coordinate of the element.
Returns
- PdfLightTableLayoutResult
The PdfLightTable layout result
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
// Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the DataTable.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the DataTable.
table.Rows.Add(new string[] { "abc", "21", "Male" });
//Assign data source.
pdfLightTable.DataSource = table;
//Draw PdfLightTable.
pdfLightTable.Draw(page, 10, 10);
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the DataTable.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the DataTable.
table.Rows.Add(New String() { "abc", "21", "Male" })
'Assign data source.
pdfLightTable.DataSource = table
'Draw PdfLightTable.
pdfLightTable.Draw(page, 10, 10)
'Save the document.
document.Save("Output.pdf")
'Close the document
Draw(PdfPage, float, float, PdfLightTableLayoutFormat)
Draw the PdfLightTable in the specified PdfPage , x,y coordinates and layout format.
public PdfLightTableLayoutResult Draw(PdfPage page, float x, float y, PdfLightTableLayoutFormat format)
Parameters
page
PdfPageThe page of the table should be drawn.
x
floatThe x co-ordinate of the element.
y
floatThe y coordinate of the element.
format
PdfLightTableLayoutFormatThe PdfLightTable layout format.
Returns
- PdfLightTableLayoutResult
The PdfLightTable layout result.
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
// Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the Data Table.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the Data Table.//you can add multiple rows
table.Rows.Add(new string[] { "abc", "21", "Male" });
//Assign data source.
pdfLightTable.DataSource = table;
//Set properties to paginate the table.
PdfLightTableLayoutFormat layoutFormat = new PdfLightTableLayoutFormat();
layoutFormat.Break = PdfLayoutBreakType.FitPage;
layoutFormat.Layout = PdfLayoutType.Paginate;
//Draw PdfLightTable.
pdfLightTable.Draw(page, 10, 10, layoutFormat);
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the Data Table.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the Data Table.//you can add multiple rows
table.Rows.Add(New String() { "abc", "21", "Male" })
'Assign data source.
pdfLightTable.DataSource = table
'Set properties to paginate the table.
Dim layoutFormat As New PdfLightTableLayoutFormat()
layoutFormat.Break = PdfLayoutBreakType.FitPage
layoutFormat.Layout = PdfLayoutType.Paginate
'Draw PdfLightTable.
pdfLightTable.Draw(page, 10, 10, layoutFormat)
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Draw(PdfPage, float, float, float)
Draw the PdfLightTable in the specified PdfPage ,x,y coordinates and width.
public PdfLightTableLayoutResult Draw(PdfPage page, float x, float y, float width)
Parameters
page
PdfPageThe page of the table should be drawn.
x
floatThe x co-ordinate of the element.
y
floatThe y coordinate of the element.
width
floatThe width of the table.
Returns
- PdfLightTableLayoutResult
The PdfLightTable layout result
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
// Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the Data Table.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the Data Table.//you can add multiple rows
table.Rows.Add(new string[] { "abc", "21", "Male" });
//Assign data source.
pdfLightTable.DataSource = table;
//Draw PdfLightTable.
pdfLightTable.Draw(page, 10, 10, 500);
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the Data Table.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the Data Table.//you can add multiple rows
table.Rows.Add(New String() { "abc", "21", "Male" })
'Assign data source.
pdfLightTable.DataSource = table
'Draw PdfLightTable.
pdfLightTable.Draw(page, 10, 10, 500)
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Draw(PdfPage, float, float, float, PdfLightTableLayoutFormat)
Draw the PdfLightTable in the specified PdfPage,x,y coordinates,width and layout format.
public PdfLightTableLayoutResult Draw(PdfPage page, float x, float y, float width, PdfLightTableLayoutFormat format)
Parameters
page
PdfPageThe page of the table should be drawn.
x
floatThe x coordinate of the element.
y
floatThe y coordinate of the element.
width
floatThe width of the table.
format
PdfLightTableLayoutFormatThe PdfLightTable layout format.
Returns
- PdfLightTableLayoutResult
The PdfLightTable layout result.
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
// Create a PdfLightTable.
PdfLightTable pdfLightTable = new PdfLightTable();
// Initialize DataTable to assign as DataSource to the light table.
DataTable table = new DataTable();
//Include columns to the Data Table.
table.Columns.Add("Name");
table.Columns.Add("Age");
table.Columns.Add("Sex");
//Include rows to the Data Table.//you can add multiple rows
table.Rows.Add(new string[] { "abc", "21", "Male" });
//Assign data source.
pdfLightTable.DataSource = table;
//Set properties to paginate the table.
PdfLightTableLayoutFormat layoutFormat = new PdfLightTableLayoutFormat();
layoutFormat.Break = PdfLayoutBreakType.FitPage;
layoutFormat.Layout = PdfLayoutType.Paginate;
//Draw PdfLightTable.
pdfLightTable.Draw(page, 10,10,500, layoutFormat);
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
' Create a PdfLightTable.
Dim pdfLightTable As New PdfLightTable()
' Initialize DataTable to assign as DataSource to the light table.
Dim table As New DataTable()
'Include columns to the Data Table.
table.Columns.Add("Name")
table.Columns.Add("Age")
table.Columns.Add("Sex")
'Include rows to the Data Table.//you can add multiple rows
table.Rows.Add(New String() { "abc", "21", "Male" })
'Assign data source.
pdfLightTable.DataSource = table
'Set properties to paginate the table.
Dim layoutFormat As New PdfLightTableLayoutFormat()
layoutFormat.Break = PdfLayoutBreakType.FitPage
layoutFormat.Layout = PdfLayoutType.Paginate
'Draw PdfLightTable.
pdfLightTable.Draw(page, 10,10,500, layoutFormat)
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
DrawInternal(PdfGraphics)
Draws an element on the Graphics.
protected override void DrawInternal(PdfGraphics graphics)
Parameters
graphics
PdfGraphicsGraphics context where the element should be printed.
Layout(PdfLayoutParams)
Layouts the element.
protected override PdfLayoutResult Layout(PdfLayoutParams param)
Parameters
param
PdfLayoutParamsLay outing parameters.
Returns
- PdfLayoutResult
Returns lay outing results.
SetDataSource()
public void SetDataSource()
Events
BeginCellLayout
The event raised on starting cell lay outing.
public event BeginCellLayoutEventHandler BeginCellLayout
Event Type
Examples
// Create a new document
PdfDocument document = new PdfDocument();
//Create a Page
PdfPage page = document.Pages.Add();
//Create DataTable for source
DataTable dataTable = new DataTable("myTable");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Roll Number", "Student Name" };
dataTable.Rows.Add(values);
values = new object[] { "011", "Cris" };
dataTable.Rows.Add(values);
values = new object[] { "011", "Clay" };
dataTable.Rows.Add(values);
//Create the PdfLightTable
PdfLightTable pdfLightTable = new PdfLightTable();
// Subscribe the cell layout event
pdfLightTable.BeginCellLayout += new BeginCellLayoutEventHandler(table_BeginCellLayout);
pdfLightTable.DataSource = dataTable;
pdfLightTable.Style.CellPadding = 16;
//Draw PdfLightTable.
pdfLightTable.Draw(page, new PointF(0, 0));
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
// Cell layout event handler
void table_BeginCellLayout(object sender, BeginCellLayoutEventArgs args)
{
if (args.RowIndex == 1)
{
args.Graphics.DrawRectangle(new PdfPen(PdfBrushes.Red, 2), PdfBrushes.White, args.Bounds);
}
}
' Create a new document
Dim document As New PdfDocument()
'Create a Page
Dim page As PdfPage = document.Pages.Add()
'Create DataTable for source
Dim dataTable As New DataTable("myTable")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Roll Number", "Student Name" }
dataTable.Rows.Add(values)
values = New Object() { "011", "Cris" }
dataTable.Rows.Add(values)
values = New Object() { "011", "Clay" }
dataTable.Rows.Add(values)
'Create the PdfLightTable
Dim pdfLightTable As New PdfLightTable()
' Subscribe the cell layout event
AddHandler pdfLightTable.BeginCellLayout, AddressOf table_BeginCellLayout
pdfLightTable.DataSource = dataTable
pdfLightTable.Style.CellPadding = 16
'Draw PdfLightTable.
pdfLightTable.Draw(page, New PointF(0, 0))
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
' Cell layout event handler
Private Sub table_BeginCellLayout(ByVal sender As Object, ByVal args As BeginCellLayoutEventArgs)
If args.RowIndex = 1 Then
args.Graphics.DrawRectangle(New PdfPen(PdfBrushes.Red, 2), PdfBrushes.White, args.Bounds)
End If
End Sub
BeginRowLayout
The event raised on starting row lay outing.
public event BeginRowLayoutEventHandler BeginRowLayout
Event Type
Examples
// Create a new document
PdfDocument document = new PdfDocument();
//Create a Page
PdfPage page = document.Pages.Add();
//Create DataTable for source
DataTable dataTable = new DataTable("myTable");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Roll Number", "Student Name" };
dataTable.Rows.Add(values);
values = new object[] { "011", "Cris" };
dataTable.Rows.Add(values);
values = new object[] { "011", "Clay" };
dataTable.Rows.Add(values);
//Create the PdfLightTable
PdfLightTable pdfLightTable = new PdfLightTable();
// Subscribe the begin row event
pdfLightTable.BeginRowLayout += new BeginRowLayoutEventHandler(table_BeginRowLayout);
//Set the data source
pdfLightTable.DataSource = dataTable;
//Draw PdfLightTable.
pdfLightTable.Draw(page, new PointF(0, 0));
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
void table_BeginRowLayout(object sender, BeginRowLayoutEventArgs args)
{
if (args.RowIndex == 1)
{
PdfLightTable table = (PdfLightTable)sender;
int count = table.Columns.Count;
int[] spanMap = new int[count];
// Set just spanned cells. Other values are not important except negatives that are not allowed.
spanMap[0] = 2;
spanMap[1] = 3;
args.ColumnSpanMap = spanMap;
//Set row height.
args.MinimalHeight = 30f;
}
}
' Create a new document
Dim document As New PdfDocument()
'Create a Page
Dim page As PdfPage = document.Pages.Add()
'Create DataTable for source
Dim dataTable As New DataTable("myTable")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Roll Number", "Student Name" }
dataTable.Rows.Add(values)
values = New Object() { "011", "Cris" }
dataTable.Rows.Add(values)
values = New Object() { "011", "Clay" }
dataTable.Rows.Add(values)
'Create the PdfLightTable
Dim pdfLightTable As New PdfLightTable()
' Subscribe the begin row event
AddHandler pdfLightTable.BeginRowLayout, AddressOf table_BeginRowLayout
'Set the data source
pdfLightTable.DataSource = dataTable
'Draw PdfLightTable.
pdfLightTable.Draw(page, New PointF(0, 0))
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Private Sub table_BeginRowLayout(ByVal sender As Object, ByVal args As BeginRowLayoutEventArgs)
If args.RowIndex = 1 Then
Dim table As PdfLightTable = CType(sender, PdfLightTable)
Dim count As Integer = table.Columns.Count
Dim spanMap(count - 1) As Integer
' Set just spanned cells. Other values are not important except negatives that are not allowed.
spanMap(0) = 2
spanMap(1) = 3
args.ColumnSpanMap = spanMap
'Set row height.
args.MinimalHeight = 30f
End If
End Sub
EndCellLayout
The event raised on having finished cell layout.
public event EndCellLayoutEventHandler EndCellLayout
Event Type
Examples
// Create a new document
PdfDocument document = new PdfDocument();
//Create a Page
PdfPage page = document.Pages.Add();
//Create DataTable for source
DataTable dataTable = new DataTable("myTable");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Roll Number", "Student Name" };
dataTable.Rows.Add(values);
values = new object[] { "011", "Cris" };
dataTable.Rows.Add(values);
values = new object[] { "011", "Clay" };
dataTable.Rows.Add(values);
//Create the PdfLightTable
PdfLightTable pdfLightTable = new PdfLightTable();
// Subscribe the cell layout event
pdfLightTable.EndCellLayout += new EndCellLayoutEventHandler(table_EndCellLayout);
pdfLightTable.DataSource = dataTable;
pdfLightTable.Style.CellPadding = 16;
//Draw PdfLightTable.
pdfLightTable.Draw(page, new PointF(0, 0));
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
// Cell layout event handler
void table_EndCellLayout(object sender, EndCellLayoutEventArgs args)
{
if (args.RowIndex == 1)
{
args.Graphics.DrawRectangle(new PdfPen(PdfBrushes.Red, 2), PdfBrushes.White, args.Bounds);
}
}
' Create a new document
Dim document As New PdfDocument()
'Create a Page
Dim page As PdfPage = document.Pages.Add()
'Create DataTable for source
Dim dataTable As New DataTable("myTable")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Roll Number", "Student Name" }
dataTable.Rows.Add(values)
values = New Object() { "011", "Cris" }
dataTable.Rows.Add(values)
values = New Object() { "011", "Clay" }
dataTable.Rows.Add(values)
'Create the PdfLightTable
Dim pdfLightTable As New PdfLightTable()
' Subscribe the cell layout event
AddHandler pdfLightTable.EndCellLayout, AddressOf table_EndCellLayout
pdfLightTable.DataSource = dataTable
pdfLightTable.Style.CellPadding = 16
'Draw PdfLightTable.
pdfLightTable.Draw(page, New PointF(0, 0))
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
' Cell layout event handler
Private Sub table_EndCellLayout(ByVal sender As Object, ByVal args As EndCellLayoutEventArgs)
If args.RowIndex = 1 Then
args.Graphics.DrawRectangle(New PdfPen(PdfBrushes.Red, 2), PdfBrushes.White, args.Bounds)
End If
End Sub
EndRowLayout
The event raised on having finished row lay outing.
public event EndRowLayoutEventHandler EndRowLayout
Event Type
Examples
// Create a new document
PdfDocument document = new PdfDocument();
//Create a Page
PdfPage page = document.Pages.Add();
//Create DataTable for source
DataTable dataTable = new DataTable("myTable");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Roll Number", "Student Name" };
dataTable.Rows.Add(values);
values = new object[] { "011", "Cris" };
dataTable.Rows.Add(values);
values = new object[] { "011", "Clay" };
dataTable.Rows.Add(values);
//Create the PdfLightTable
PdfLightTable pdfLightTable = new PdfLightTable();
//Set the data source
pdfLightTable.DataSource = dataTable;
// Subscribe the end row event
pdfLightTable.EndRowLayout += new EndRowLayoutEventHandler(table_EndRowLayout);
//Draw PdfLightTable.
pdfLightTable.Draw(page, new PointF(0, 0));
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
void table_EndRowLayout(object sender, EndRowLayoutEventArgs args)
{
if (args.RowIndex == 1)
{
// Cancel property used to cancel the table rendering operation
args.Cancel = true;
}
}
' Create a new document
Dim document As New PdfDocument()
'Create a Page
Dim page As PdfPage = document.Pages.Add()
'Create DataTable for source
Dim dataTable As New DataTable("myTable")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = { "Roll Number", "Student Name" }
dataTable.Rows.Add(values)
values = New Object() { "011", "Cris" }
dataTable.Rows.Add(values)
values = New Object() { "011", "Clay" }
dataTable.Rows.Add(values)
'Create the PdfLightTable
Dim pdfLightTable As New PdfLightTable()
'Set the data source
pdfLightTable.DataSource = dataTable
' Subscribe the end row event
AddHandler pdfLightTable.EndRowLayout, AddressOf table_EndRowLayout
'Draw PdfLightTable.
pdfLightTable.Draw(page, New PointF(0, 0))
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Private Sub table_EndRowLayout(ByVal sender As Object, ByVal args As EndRowLayoutEventArgs)
If args.RowIndex = 1 Then
' Cancel property used to cancel the table rendering operation
args.Cancel = True
End If
End Sub
QueryColumnCount
The event raised when the column number is requested.
public event QueryColumnCountEventHandler QueryColumnCount
Event Type
Examples
public string[][] datastring = new string[2][];
// Specify values for the table
datastring[0] = new string[] { "111", "Maxim", "100" };
datastring[1] = new string[] { "222", "Calvin", "95" };
// Create a new document
PdfDocument document = new PdfDocument();
//Create a Page
PdfPage page = document.Pages.Add();
//Create the PdfLightTable
PdfLightTable pdfLightTable = new PdfLightTable();
// Setting the DataSourceType as Direct
pdfLightTable.DataSourceType = PdfLightTableDataSourceType.External;
//Subscribing Events
pdfLightTable.QueryColumnCount += new QueryColumnCountEventHandler(table_QueryColumnCount);
pdfLightTable.QueryNextRow += new QueryNextRowEventHandler(table_QueryNextRow);
//Draw PdfLightTable.
pdfLightTable.Draw(page, new PointF(0, 0));
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
void table_QueryColumnCount(object sender, QueryColumnCountEventArgs args)
{
args.ColumnCount = 3;
}
void table_QueryNextRow(object sender, QueryNextRowEventArgs args)
{
if (datastring.Length > args.RowIndex)
args.RowData = new string[] { datastring[args.RowIndex][0], datastring[args.RowIndex][1], datastring[args.RowIndex][2] };
}
Public datastring(2)() As String
' Specify values for the table
datastring(0) = New String() { "111", "Maxim", "100" }
datastring(1) = New String() { "222", "Calvin", "95" }
' Create a new document' Create a new document
Dim document As New PdfDocument()
'Create a Page
Dim page As PdfPage = document.Pages.Add()
'Create the PdfLightTable
Dim pdfLightTable As New PdfLightTable()
' Setting the DataSourceType as Direct
pdfLightTable.DataSourceType = PdfLightTableDataSourceType.External
'Subscribing Events
AddHandler pdfLightTable.QueryColumnCount, AddressOf table_QueryColumnCount
AddHandler pdfLightTable.QueryNextRow, AddressOf table_QueryNextRow
'Draw PdfLightTable.
pdfLightTable.Draw(page, New PointF(0, 0))
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Private Sub table_QueryColumnCount(ByVal sender As Object, ByVal args As QueryColumnCountEventArgs)
args.ColumnCount = 3
End Sub
Private Sub table_QueryNextRow(ByVal sender As Object, ByVal args As QueryNextRowEventArgs)
If datastring.Length > args.RowIndexThen
args.RowData = New String() { datastring(args.RowIndex)(0), datastring(args.RowIndex)(1), datastring(args.RowIndex)(2) }
End If
End Sub
QueryNextRow
The event raised when the next row data is requested.
public event QueryNextRowEventHandler QueryNextRow
Event Type
Examples
public string[][] datastring = new string[2][];
// Specify values for the table
datastring[0] = new string[] { "111", "Maxim", "100" };
datastring[1] = new string[] { "222", "Calvin", "95" };
// Create a new document
PdfDocument document = new PdfDocument();
//Create a Page
PdfPage page = document.Pages.Add();
//Create the PdfLightTable
PdfLightTable pdfLightTable = new PdfLightTable();
// Setting the DataSourceType as Direct
pdfLightTable.DataSourceType = PdfLightTableDataSourceType.External;
//Subscribing Events
pdfLightTable.QueryColumnCount += new QueryColumnCountEventHandler(table_QueryColumnCount);
pdfLightTable.QueryNextRow += new QueryNextRowEventHandler(table_QueryNextRow);
//Draw PdfLightTable.
pdfLightTable.Draw(page, new PointF(0, 0));
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
void table_QueryColumnCount(object sender, QueryColumnCountEventArgs args)
{
args.ColumnCount = 3;
}
void table_QueryNextRow(object sender, QueryNextRowEventArgs args)
{
if (datastring.Length > args.RowIndex)
args.RowData = new string[] { datastring[args.RowIndex][0], datastring[args.RowIndex][1], datastring[args.RowIndex][2] };
}
Public datastring(2)() As String
' Specify values for the table
datastring(0) = New String() { "111", "Maxim", "100" }
datastring(1) = New String() { "222", "Calvin", "95" }
' Create a new document' Create a new document
Dim document As New PdfDocument()
'Create a Page
Dim page As PdfPage = document.Pages.Add()
'Create the PdfLightTable
Dim pdfLightTable As New PdfLightTable()
' Setting the DataSourceType as Direct
pdfLightTable.DataSourceType = PdfLightTableDataSourceType.External
'Subscribing Events
AddHandler pdfLightTable.QueryColumnCount, AddressOf table_QueryColumnCount
AddHandler pdfLightTable.QueryNextRow, AddressOf table_QueryNextRow
'Draw PdfLightTable.
pdfLightTable.Draw(page, New PointF(0, 0))
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Private Sub table_QueryColumnCount(ByVal sender As Object, ByVal args As QueryColumnCountEventArgs)
args.ColumnCount = 3
End Sub
Private Sub table_QueryNextRow(ByVal sender As Object, ByVal args As QueryNextRowEventArgs)
If datastring.Length > args.RowIndex Then
args.RowData = New String() { datastring(args.RowIndex)(0), datastring(args.RowIndex)(1), datastring(args.RowIndex)(2) }
End If
End Sub
QueryRowCount
The event raised when the row number is requested.
public event QueryRowCountEventHandler QueryRowCount
Event Type
Examples
public string[][] datastring = new string[3][];
// Specify values for the table
datastring[0] = new string[] { "111", "Maxim", "100" };
datastring[1] = new string[] { "222", "Calvin", "95" };
datastring[2] = new string[] { "333", "Criss", "99" };
// Create a new document
PdfDocument document = new PdfDocument();
//Create a Page
PdfPage page = document.Pages.Add();
//Create the PdfLightTable
PdfLightTable pdfLightTable = new PdfLightTable();
// Setting the DataSourceType as Direct
pdfLightTable.DataSourceType = PdfLightTableDataSourceType.External;
//Subscribing Events
pdfLightTable.QueryRowCount += new QueryRowCountEventHandler(table_QueryRowCount);
pdfLightTable.QueryColumnCount += new QueryColumnCountEventHandler(table_QueryColumnCount);
pdfLightTable.QueryNextRow += new QueryNextRowEventHandler(table_QueryNextRow);
//Draw PdfLightTable.
pdfLightTable.Draw(page, new PointF(0, 0));
//Save the document.
document.Save("Output.pdf");
//Close the document
document.Close(true);
void table_QueryColumnCount(object sender, QueryColumnCountEventArgs args)
{
args.ColumnCount = 3;
}
void table_QueryNextRow(object sender, QueryNextRowEventArgs args)
{
if (datastring.Length > args.RowIndex)
args.RowData = new string[] { datastring[args.RowIndex][0], datastring[args.RowIndex][1], datastring[args.RowIndex][2] };
}
void table_QueryRowCount(object sender, QueryRowCountEventArgs args)
{
args.RowCount = 2;
}
Public datastring(2)() As String
' Specify values for the table
datastring(0) = New String() { "111", "Maxim", "100" }
datastring(1) = New String() { "222", "Calvin", "95" }
datastring(2) = New String() { "333", "Criss", "99" }
' Create a new document
Dim document As New PdfDocument()
'Create a Page
Dim page As PdfPage = document.Pages.Add()
'Create the PdfLightTable
Dim pdfLightTable As New PdfLightTable()
' Setting the DataSourceType as Direct
pdfLightTable.DataSourceType = PdfLightTableDataSourceType.External
'Subscribing Events
AddHandler pdfLightTable.QueryRowCount, AddressOf table_QueryRowCount
AddHandler pdfLightTable.QueryColumnCount, AddressOf table_QueryColumnCount
AddHandler pdfLightTable.QueryNextRow, AddressOf table_QueryNextRow
'Draw PdfLightTable.
pdfLightTable.Draw(page, New PointF(0, 0))
'Save the document.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Private Sub table_QueryColumnCount(ByVal sender As Object, ByVal args As QueryColumnCountEventArgs)
args.ColumnCount = 3
End Sub
Private Sub table_QueryNextRow(ByVal sender As Object, ByVal args As QueryNextRowEventArgs)
If datastring.Length > args.RowIndex Then
args.RowData = New String() { datastring(args.RowIndex)(0), datastring(args.RowIndex)(1), datastring(args.RowIndex)(2) }
End If
End Sub
Private Sub table_QueryRowCount(ByVal sender As Object, ByVal args As QueryRowCountEventArgs)
args.RowCount = 2
End Sub