Class PdfGrid
Represents a flexible grid that consists of columns and rows.
Inherited Members
Namespace: Syncfusion.Pdf.Grid
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfGrid : PdfLayoutElement
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Draw grid to the page of PDF document.
pdfGrid.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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Constructors
PdfGrid()
Initializes a new instance of the PdfGrid class.
Declaration
public PdfGrid()
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Draw grid to the page of PDF document.
pdfGrid.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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Properties
AllowRowBreakAcrossPages
Gets or sets a value indicating whether to split or cut rows that overflow a page.
Declaration
public bool AllowRowBreakAcrossPages { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
Default Value: true
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Set row break.
pdfGrid.AllowRowBreakAcrossPages = true;
//Get the rows collection from the PdfGrid
PdfGridRowCollection rowCollection = pdfGrid.Rows;
rowCollection[0].Cells[0].Value = "Row Collection Sample";
//Draw grid to the page of PDF document.
pdfGrid.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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Set row break.
pdfGrid.AllowRowBreakAcrossPages = True
'Get the rows collection from the PdfGrid
Dim rowCollection As PdfGridRowCollection = pdfGrid.Rows
rowCollection(0).Cells(0).Value = "Row Collection Sample"
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Columns
Gets the column collection of the PdfGrid.[Read-Only]
Declaration
public PdfGridColumnCollection Columns { get; }
Property Value
Type | Description |
---|---|
PdfGridColumnCollection | Represents the columns collection of the PdfGrid. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Get the column collection from the PdfGrid
PdfGridColumnCollection columnCollection = pdfGrid.Columns;
columnCollection[0].Width = 100;
//Draw grid to the page of PDF document.
pdfGrid.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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Get the column collection from the PdfGrid
Dim columnCollection As PdfGridColumnCollection = pdfGrid.Columns
columnCollection(0).Width = 100
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
DataMember
Gets or sets the data member.
Declaration
public string DataMember { get; set; }
Property Value
Type | Description |
---|---|
System.String | The data member. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable("EmpDetails");
//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" });
//Create data table.
DataTable stdTable = new DataTable("StdTable"); ///
/Add columns
stdTable.Columns.Add("ID");
stdTable.Columns.Add("Name");
//Add rows.
stdTable.Rows.Add(new object[] { "S01", "George" });
stdTable.Rows.Add(new object[] { "S02", "Stefan" });
//Create new data set.
DataSet dataSet = new DataSet();
dataSet.Tables.Add(dataTable);
dataSet.Tables.Add(stdTable);
//Set data member.
pdfGrid.DataMember = "StdTable";
//Assign data source.
pdfGrid.DataSource = dataSet;
//Draw grid to the page of PDF document.
pdfGrid.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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable("EmpDetails")
'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"})
'Create data table.
Dim stdTable As New DataTable("StdTable")
'Add columns
stdTable.Columns.Add("ID")
stdTable.Columns.Add("Name")
'Add rows.
stdTable.Rows.Add(New Object() { "S01", "George"})
stdTable.Rows.Add(New Object() { "S02", "Stefan"})
'Create new data set.
Dim dataSet As New DataSet()
dataSet.Tables.Add(dataTable)
dataSet.Tables.Add(stdTable)
'Set data member.
pdfGrid.DataMember = "StdTable"
'Assign data source.
pdfGrid.DataSource = dataSet
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
DataSource
Gets or sets the data bind to the PdfGrid by associating it with an external data source.
Declaration
public object DataSource { get; set; }
Property Value
Type | Description |
---|---|
System.Object | The data source. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Draw grid to the page of PDF document.
pdfGrid.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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Headers
Gets the headers collection from the PdfGrid.[Read-Only]
Declaration
public PdfGridHeaderCollection Headers { get; }
Property Value
Type | Description |
---|---|
PdfGridHeaderCollection | Represents the headers of the PdfGrid. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable();
//Add columns to the DataTable
dataTable.Columns.Add();
dataTable.Columns.Add();
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
// Add a new header to PdfGrid.
pdfGrid.Headers.Add(1);
// Get the header collection.
PdfGridHeaderCollection collection = pdfGrid.Headers;
// Set the header names.
collection[0].Cells[0].Value = "Header1";
collection[0].Cells[1].Value = "Header2";
//Draw grid to the page of PDF document.
pdfGrid.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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable()
'Add columns to the DataTable
dataTable.Columns.Add()
dataTable.Columns.Add()
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() {"E01", "Clay"})
dataTable.Rows.Add(New Object() {"E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
' Add a new header to PdfGrid.
pdfGrid.Headers.Add(1)
' Get the header collection.
Dim collection As PdfGridHeaderCollection = pdfGrid.Headers
' Set the header names.
collection(0).Cells(0).Value = "Header1"
collection(0).Cells(1).Value = "Header2"
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
RepeatHeader
Gets or sets a value indicating whether to repeat header.
Declaration
public bool RepeatHeader { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
Default value: false
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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.
for (int i = 0; i != 100; i++)
dataTable.Rows.Add(new object[] { "Cell[0][" + i.ToString() + "]",
"Cell[1][" + i.ToString() + "]" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//To repeat the header across pages
pdfGrid.RepeatHeader = true;
//Draw grid to the page of PDF document.
pdfGrid.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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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.
For i As Integer = 0 To 99
dataTable.Rows.Add(New Object() {"Cell[0][" + i.ToString() + "]", "Cell[1][" + i.ToString() + "]"})
Next i
'Assign data source.
pdfGrid.DataSource = dataTable
'To repeat the header across pages
pdfGrid.RepeatHeader = True
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Rows
Gets the row collection from the PdfGrid.[Read-Only]
Declaration
public PdfGridRowCollection Rows { get; }
Property Value
Type | Description |
---|---|
PdfGridRowCollection | Represents the rows collection of the PdfGrid. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Get the rows collection from the PdfGrid
PdfGridRowCollection rowCollection = pdfGrid.Rows;
rowCollection[0].Cells[0].Value = "Row Collection Sample";
//Draw grid to the page of PDF document.
pdfGrid.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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Get the rows collection from the PdfGrid
Dim rowCollection As PdfGridRowCollection = pdfGrid.Rows
rowCollection(0).Cells(0).Value = "Row Collection Sample"
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Style
Gets or sets the grid style.
Declaration
public PdfGridStyle Style { get; set; }
Property Value
Type | Description |
---|---|
PdfGridStyle | Represents the style information applied to a PdfGrid. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Adding different style
PdfGridStyle style = new PdfGridStyle();
style.BackgroundBrush = PdfBrushes.Cyan;
style.TextBrush = PdfBrushes.BlueViolet;
style.TextPen = new PdfPen(PdfBrushes.Black, 0.25F);
//Add style to the PdfGrid
pdfGrid.Style = style;
//Draw grid to the page of PDF document.
pdfGrid.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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Adding different style
Dim style As New PdfGridStyle()
style.BackgroundBrush = PdfBrushes.Cyan
style.TextBrush = PdfBrushes.BlueViolet
style.TextPen = New PdfPen(PdfBrushes.Black, 0.25F)
'Add style to the PdfGrid
pdfGrid.Style = style
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Methods
add_BeginCellLayout(PdfGridBeginCellLayoutEventHandler)
Declaration
public void add_BeginCellLayout(PdfGridBeginCellLayoutEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PdfGridBeginCellLayoutEventHandler | value |
add_EndCellLayout(PdfGridEndCellLayoutEventHandler)
Declaration
public void add_EndCellLayout(PdfGridEndCellLayoutEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PdfGridEndCellLayoutEventHandler | value |
ApplyBuiltinStyle(PdfGridBuiltinStyle)
Apply built-in table style to the grid.
Declaration
public void ApplyBuiltinStyle(PdfGridBuiltinStyle gridStyle)
Parameters
Type | Name | Description |
---|---|---|
PdfGridBuiltinStyle | gridStyle |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a new PDF grid instance.
PdfGrid table = new PdfGrid();
//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(PdfGridBuiltinStyle.GridTable3);
//Draw grid 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 grid instance.
Dim table As New PdfGrid()
'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(PdfGridBuiltinStyle.GridTable3)
'Draw grid 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(PdfGridBuiltinStyle, PdfGridBuiltinStyleSettings)
Apply built-in table style to the table
Declaration
public void ApplyBuiltinStyle(PdfGridBuiltinStyle gridStyle, PdfGridBuiltinStyleSettings gridStyleSetting)
Parameters
Type | Name | Description |
---|---|---|
PdfGridBuiltinStyle | gridStyle | enum of PdfGridBuiltinStyle |
PdfGridBuiltinStyleSettings | gridStyleSetting | The PdfGridBuiltinStyleSettings |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a new PDF grid instance.
PdfGrid table = new PdfGrid();
//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 grid build style settings instance.
PdfGridBuiltinStyleSettings settings = new PdfGridBuiltinStyleSettings();
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(PdfGridBuiltinStyle.GridTable3, settings);
//Draw grid 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 grid instance.
Dim table As New PdfGrid()
'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 grid build style settings instance.
Dim settings As New PdfGridBuiltinStyleSettings()
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(PdfGridBuiltinStyle.GridTable3, settings)
'Draw grid 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, Single)
Draws the PdfGrid in the specified graphics.
Declaration
public void Draw(PdfGraphics graphics, PointF location, float width)
Parameters
Type | Name | Description |
---|---|---|
PdfGraphics | graphics | The graphics. |
System.Drawing.PointF | location | The location. |
System.Single | width | The width. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page.Graphics, new PointF(10, 10), 100);
//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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Draw grid to the page of PDF document.
pdfGrid.Draw(page.Graphics, New PointF(10, 10), 100)
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Draw(PdfGraphics, RectangleF)
Draws the PdfGrid in the specified graphics.
Declaration
public void Draw(PdfGraphics graphics, RectangleF bounds)
Parameters
Type | Name | Description |
---|---|---|
PdfGraphics | graphics | The graphics. |
System.Drawing.RectangleF | bounds | The bounds. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page.Graphics, new RectangleF(0, 0, 100, 100));
//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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Draw grid to the page of PDF document.
pdfGrid.Draw(page.Graphics, New RectangleF(0, 0, 100, 100))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Draw(PdfGraphics, Single, Single, Single)
Draws the PdfGrid in the specified graphics.
Declaration
public void Draw(PdfGraphics graphics, float x, float y, float width)
Parameters
Type | Name | Description |
---|---|---|
PdfGraphics | graphics | The graphics. |
System.Single | x | The x. |
System.Single | y | The y. |
System.Single | width | The width. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page.Graphics, 10, 10, 100);
//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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Draw grid to the page of PDF document.
pdfGrid.Draw(page.Graphics, 10, 10, 100)
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Draw(PdfPage, PointF)
Declaration
public PdfGridLayoutResult Draw(PdfPage page, PointF location)
Parameters
Type | Name | Description |
---|---|---|
PdfPage | page | The page. |
System.Drawing.PointF | location | The location. |
Returns
Type | Description |
---|---|
PdfGridLayoutResult | The grid layout result |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Draw grid to the page of PDF document.
pdfGrid.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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Draw(PdfPage, PointF, PdfGridLayoutFormat)
Declaration
public PdfGridLayoutResult Draw(PdfPage page, PointF location, PdfGridLayoutFormat format)
Parameters
Type | Name | Description |
---|---|---|
PdfPage | page | The page. |
System.Drawing.PointF | location | The location. |
PdfGridLayoutFormat | format | The format. |
Returns
Type | Description |
---|---|
PdfGridLayoutResult | The grid layout result |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Creating layout format
PdfGridLayoutFormat format=new PdfGridLayoutFormat();
format.Layout=PdfLayoutType.Paginate;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10), format);
//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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Creating layout format
Dim format As New PdfGridLayoutFormat()
format.Layout = PdfLayoutType.Paginate
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10), format)
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Draw(PdfPage, RectangleF)
Declaration
public PdfGridLayoutResult Draw(PdfPage page, RectangleF bounds)
Parameters
Type | Name | Description |
---|---|---|
PdfPage | page | The page. |
System.Drawing.RectangleF | bounds | The bounds. |
Returns
Type | Description |
---|---|
PdfGridLayoutResult | The grid layout result |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new RectangleF(0, 0, 100, 100));
//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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New RectangleF(0, 0, 100, 100))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Draw(PdfPage, RectangleF, PdfGridLayoutFormat)
Declaration
public PdfGridLayoutResult Draw(PdfPage page, RectangleF bounds, PdfGridLayoutFormat format)
Parameters
Type | Name | Description |
---|---|---|
PdfPage | page | The page. |
System.Drawing.RectangleF | bounds | The bounds. |
PdfGridLayoutFormat | format | The format. |
Returns
Type | Description |
---|---|
PdfGridLayoutResult | The grid layout result |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Creating layout format
PdfGridLayoutFormat format=new PdfGridLayoutFormat();
format.Layout=PdfLayoutType.Paginate;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new RectangleF(0, 0, 100, 100), format);
//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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Creating layout format
Dim format As New PdfGridLayoutFormat()
format.Layout = PdfLayoutType.Paginate
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New RectangleF(0, 0, 100, 100), format)
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Draw(PdfPage, Single, Single)
Declaration
public PdfGridLayoutResult Draw(PdfPage page, float x, float y)
Parameters
Type | Name | Description |
---|---|---|
PdfPage | page | The page. |
System.Single | x | The x. |
System.Single | y | The y. |
Returns
Type | Description |
---|---|
PdfGridLayoutResult | The grid layout result |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, 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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, 10, 10)
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Draw(PdfPage, Single, Single, PdfGridLayoutFormat)
Declaration
public PdfGridLayoutResult Draw(PdfPage page, float x, float y, PdfGridLayoutFormat format)
Parameters
Type | Name | Description |
---|---|---|
PdfPage | page | The page. |
System.Single | x | The x. |
System.Single | y | The y. |
PdfGridLayoutFormat | format | The format. |
Returns
Type | Description |
---|---|
PdfGridLayoutResult | The grid layout result |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Creating layout format
PdfGridLayoutFormat format=new PdfGridLayoutFormat();
format.Layout=PdfLayoutType.Paginate;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, 10, 10, format);
//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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Creating layout format
Dim format As New PdfGridLayoutFormat()
format.Layout = PdfLayoutType.Paginate
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, 10, 10, format)
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Draw(PdfPage, Single, Single, Single)
Declaration
public PdfGridLayoutResult Draw(PdfPage page, float x, float y, float width)
Parameters
Type | Name | Description |
---|---|---|
PdfPage | page | The page. |
System.Single | x | The x. |
System.Single | y | The y. |
System.Single | width | The width. |
Returns
Type | Description |
---|---|
PdfGridLayoutResult | The grid layout result |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, 10, 10, 100);
//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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, 10, 10, 100)
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Draw(PdfPage, Single, Single, Single, PdfGridLayoutFormat)
Declaration
public PdfGridLayoutResult Draw(PdfPage page, float x, float y, float width, PdfGridLayoutFormat format)
Parameters
Type | Name | Description |
---|---|---|
PdfPage | page | The page. |
System.Single | x | The x. |
System.Single | y | The y. |
System.Single | width | The width. |
PdfGridLayoutFormat | format | The format. |
Returns
Type | Description |
---|---|
PdfGridLayoutResult | The grid layout result |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//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" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Creating layout format
PdfGridLayoutFormat format=new PdfGridLayoutFormat();
format.Layout=PdfLayoutType.Paginate;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, 10, 10, 100, format);
//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 PdfGrid.
Dim pdfGrid As New PdfGrid()
'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"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Creating layout format
Dim format As New PdfGridLayoutFormat()
format.Layout = PdfLayoutType.Paginate
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, 10, 10, 100, format)
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Layout(PdfLayoutParams)
Layouts the element.
Declaration
protected override PdfLayoutResult Layout(PdfLayoutParams param)
Parameters
Type | Name | Description |
---|---|---|
PdfLayoutParams | param | Layout parameters. |
Returns
Type | Description |
---|---|
PdfLayoutResult | Returns the results of layout. |
Overrides
remove_BeginCellLayout(PdfGridBeginCellLayoutEventHandler)
Declaration
public void remove_BeginCellLayout(PdfGridBeginCellLayoutEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PdfGridBeginCellLayoutEventHandler | value |
remove_EndCellLayout(PdfGridEndCellLayoutEventHandler)
Declaration
public void remove_EndCellLayout(PdfGridEndCellLayoutEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PdfGridEndCellLayoutEventHandler | value |
Events
BeginCellLayout
The event raised on starting cell lay outing.
Declaration
public event PdfGridBeginCellLayoutEventHandler BeginCellLayout
Event Type
Type |
---|
PdfGridBeginCellLayoutEventHandler |
Examples
// Creates a new document
PdfDocument doc = new PdfDocument();
RectangleF rect = new RectangleF(0, 0, 500, 50);
//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);
PdfPage page = doc.Pages.Add();
PdfPageTemplateElement top = new PdfPageTemplateElement(rect);
PdfGrid table=new PdfGrid();
// Subscribe the cell layout event
table.BeginCellLayout += new PdfGridBeginCellLayoutEventHandler(table_BeginCellLayout);
table.DataSource = dataTable;
// Draws the table in page
table.Draw(page.Graphics);
doc.Save("Tables.pdf");
// Cell layout event handler
void table_BeginCellLayout(object sender,PdfGridBeginCellLayoutEventArgs args)
{
if (args.RowIndex == 1)
{
args.Graphics.DrawRectangle(new PdfPen(PdfBrushes.Red, 2), PdfBrushes.White,args.Bounds);
}
}
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
Dim rect As RectangleF = New RectangleF(0, 0, 500, 50)
'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() { "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)
Dim page As PdfPage = doc.Pages.Add()
Dim top As PdfPageTemplateElement = New PdfPageTemplateElement(rect)
Dim table As PdfGrid = New PdfGrid()
' Subscribe the cell layout event
AddHandler table.BeginCellLayout, AddressOf table_BeginCellLayout
table.DataSource = dataTable
' Draws the table in page
table.Draw(page.Graphics)
doc.Save("Tables.pdf")
' Cell layout event handler
Private Sub table_BeginCellLayout(ByVal sender As Object, ByVal args As PdfGridBeginCellLayoutEventArgs)
If args.RowIndex = 1 Then
args.Graphics.DrawRectangle(New PdfPen(PdfBrushes.Red, 2), PdfBrushes.White,args.Bounds)
End If
End Sub
EndCellLayout
The event raised on finished cell layout.
Declaration
public event PdfGridEndCellLayoutEventHandler EndCellLayout
Event Type
Type |
---|
PdfGridEndCellLayoutEventHandler |
Examples
// Creates a new document
PdfDocument doc = new PdfDocument();
RectangleF rect = new RectangleF(0, 0, 500, 50);
//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);
PdfPage page = doc.Pages.Add();
PdfPageTemplateElement top = new PdfPageTemplateElement(rect);
PdfGrid table = new PdfGrid();
// Subscribe the cell layout event
table.EndCellLayout += new PdfGridEndCellLayoutEventHandler(table_EndCellLayout);
table.DataSource = dataTable;
table.Style.CellPadding = 16;
// Draws the table in page
table.Draw(page.Graphics);
doc.Save("Tables.pdf");
// Cell layout event handler
void table_EndCellLayout(object sender, PdfGridEndCellLayoutEventArgs args)
{
if (args.RowIndex == 1)
{
args.Graphics.DrawRectangle(new PdfPen(PdfBrushes.Red, 2), PdfBrushes.White, args.Bounds);
}
}
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
Dim rect As RectangleF = New RectangleF(0, 0, 500, 50)
'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() { "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)
Dim page As PdfPage = doc.Pages.Add()
Dim top As PdfPageTemplateElement = New PdfPageTemplateElement(rect)
Dim table As PdfGrid = New PdfGrid()
' Subscribe the cell layout event
AddHandler table.EndCellLayout, AddressOf table_EndCellLayout
table.DataSource = dataTable
table.Style.CellPadding = 16
' Draws the table in page
table.Draw(page.Graphics)
doc.Save("Tables.pdf")
' Cell layout event handler
Private Sub table_EndCellLayout(ByVal sender As Object, ByVal args As PdfGridEndCellLayoutEventArgs)
If args.RowIndex = 1 Then
args.Graphics.DrawRectangle(New PdfPen(PdfBrushes.Red, 2), PdfBrushes.White, args.Bounds)
End If
End Sub