Table2
Represents a table with rows, columns and cells.
public class Table2 : RotatingPageElement, IArea, ICoordinate, ISerializable
Public Class Table2
Inherits RotatingPageElement
Implements IArea, ICoordinate, ISerializable
Inheritance: ObjectPageElementTaggablePageElementRotatingPageElementTable2
Implements: IArea, ICoordinate, ISerializable
Licensing Info
This class is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
Examples
The following example will display a simple table on the page.Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
Module MyModule
Sub Main()
' Create a PDF Document
Dim MyDocument As Document = New Document
' Create a Page and add it to the document
Dim MyPage As Page = New Page
MyDocument.Pages.Add(MyPage)
' Create a table
Dim MyTable As Table = New Table(0, 0, 600, 600)
' Add columns to the table
MyTable.Columns.Add(150)
MyTable.Columns.Add(90)
MyTable.Columns.Add(90)
MyTable.Columns.Add(90)
' Add rows to the table and add cells to the rows
Dim row1 As Row = MyTable.Rows.Add(40, ceTe.DynamicPDF.Font.HelveticaBold, _
16, Grayscale.Black, Grayscale.Gray)
row1.Align = TextAlign.Center
row1.VAlign = VAlign.Center
row1.Cells.Add("Header 1")
row1.Cells.Add("Header 2")
row1.Cells.Add("Header 3")
row1.Cells.Add("Header 4")
Dim row2 As Row = MyTable.Rows.Add(30)
Dim cell1 As Cell = row2.Cells.Add("Rowheader 1", Font.HelveticaBold, 16, _
Grayscale.Black, Grayscale.Gray, 1)
cell1.Align = CellAlign.Center
cell1.VAlign = CellVAlign.Center
row2.Cells.Add("Item 1")
row2.Cells.Add("Item 2")
row2.Cells.Add("Item 3")
Dim row3 As Row = MyTable.Rows.Add(30)
Dim cell2 As Cell = row3.Cells.Add("Rowheader 2", Font.HelveticaBold, 16, _
Grayscale.Black, Grayscale.Gray, 1)
cell2.Align = CellAlign.Center
cell2.VAlign = CellVAlign.Center
row3.Cells.Add("Item 4")
row3.Cells.Add("Item 5")
row3.Cells.Add("Item 6")
' Add the table to the page
MyPage.Elements.Add(MyTable)
' Save the PDF
MyDocument.Draw("C:\MyDocument.pdf")
End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
public class Example
{
public static void CreatePDF(string outputPath)
{
// Create a PDF Document
Document document = new Document();
// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page);
// Create a table
Table2 table = new Table2(0, 0, 600, 600);
//Add columns to the table
Column2 column1 = table.Columns.Add(150);
column1.CellDefault.Align = TextAlign.Center;
table.Columns.Add(90);
table.Columns.Add(90);
table.Columns.Add(90);
// Add rows to the table and add cells to the rows
Row2 row1 = table.Rows.Add(40, Font.HelveticaBold, 16, Grayscale.Black,
Grayscale.Gray);
row1.CellDefault.Align = TextAlign.Center;
row1.CellDefault.VAlign = VAlign.Center;
row1.Cells.Add("Header 1");
row1.Cells.Add("Header 2");
row1.Cells.Add("Header 3");
row1.Cells.Add("Header 4");
Row2 row2 = table.Rows.Add(30);
Cell2 cell1 = row2.Cells.Add("Rowheader 1", Font.HelveticaBold, 16,
Grayscale.Black, Grayscale.Gray, 1);
cell1.Align = TextAlign.Center;
cell1.VAlign = VAlign.Center;
row2.Cells.Add("Item 1");
row2.Cells.Add("Item 2");
row2.Cells.Add("Item 3");
Row2 row3 = table.Rows.Add(30);
Cell2 cell2 = row3.Cells.Add("Rowheader 2", Font.HelveticaBold, 16,
Grayscale.Black, Grayscale.Gray, 1);
cell2.Align = TextAlign.Center;
cell2.VAlign = VAlign.Center;
row3.Cells.Add("Item 4");
row3.Cells.Add("Item 5");
row3.Cells.Add("Item 6");
table.CellDefault.Padding.Value = 5.0f;
table.CellSpacing = 5.0f;
table.Border.Top.Color = RgbColor.Blue;
table.Border.Bottom.Color = RgbColor.Blue;
table.Border.Top.Width = 2;
table.Border.Bottom.Width = 2;
table.Border.Left.LineStyle = LineStyle.None;
table.Border.Right.LineStyle = LineStyle.None;
// Add the table to the page
page.Elements.Add(table);
// Save the PDF
document.Draw(outputPath);
}
}
Remarks
This class can be used to create tables. A table must contain at least one Column and one Row with at least one Cell in that Row. Formatting of each cell in the table is done in a hierarchical manner in that a Cell's formatting take precedent over a Row's formatting which in term takes precedent over a Column's formatting which in term takes precedent over a Table's formatting . Using the AdvancedTables GetOverflowColumns and GetOverflowRows methods you can allow your table to easily flow onto other pages. See the Tables topic for more on tables.
Constructors
Table2(Single, Single, Single, Single) | Initializes a new instance of the Table2 class. |
Table2(Single, Single, Single, Single, Font, Single?) | Initializes a new instance of the Table2 class. |
Table2(Single, Single, Single, Single, Font, Single?, Color, Color) | Initializes a new instance of the Table2 class. |
Properties
Angle | Gets or sets the heights of the angle element. (Inherited from RotatingPageElement) |
BackgroundColor | Gets the Color object to use for the background of the table. |
Border | Gets the Border object to use for the border of the table. |
CellDefault | Gets the CellDefault object of the cells in the table. |
CellSpacing | Gets or sets the cellSpacing for the cells in the table. |
Columns | Gets the Column2List object contained in the table. |
Height | Gets or sets the height of the table. |
ID | Gets or sets the ID of the page element. (Inherited from PageElement) |
IgnoreMargins | Gets or sets ignore margin property. Setting false will consider the margin while placing the page element based on the RelativeTo property. (Inherited from PageElement) |
RelativeTo | Gets and sets placement of the page element on the page. (Inherited from PageElement) |
RepeatColumnHeaderCount | Gets or sets the number of initial rows in the table that should also be drawn as the first rows on all subsequent row overflow tables. This is set to 0 by default. |
RepeatRowHeaderCount | Gets or sets the number of columns that will be repeated as the row header. This number is only considered if RepeatColumnHeader is set to true. This is set to 1 by default. |
Rows | Gets the Row2List object contained in the table. |
Tag | Gets or sets the tag of the taggable element. (Inherited from TaggablePageElement) |
TagOrder | Gets or sets the tag order of the taggable element. (Inherited from TaggablePageElement) |
VisibleStartColumn | Returns the table starting column number. |
VisibleStartRow | Returns the table starting row number. |
Width | Gets or sets the width of the table. |
X | Gets or sets the X coordinate of the page element. (Inherited from RotatingPageElement) |
Y | Gets or sets the Y coordinate of the page element. (Inherited from RotatingPageElement) |
Methods
Draw(PageWriter) | Draws the page element to the given PageWriter object. (Inherited from RotatingPageElement) |
Equals(Object) | Determines whether the specified Object is equal to the current Object . (Inherited from Object) |
GetHashCode() | Serves as a hash function for a particular type. (Inherited from Object) |
GetOverflowColumns() | Returns a Table2 object containing the overflow columns. |
GetOverflowColumns(Single, Single) | Returns a Table2 object containing the overflow columns. |
GetOverflowColumns(Single, Single, Single, Single) | Returns a Table2 object containing the overflow columns. |
GetOverflowRows() | Returns a Table2 object containing the overflow rows. |
GetOverflowRows(Single, Single) | Returns a Table2 object containing the overflow rows. |
GetOverflowRows(Single, Single, Single, Single) | Returns a Table2 object containing the overflow rows. |
GetRequiredHeight() | Returns the height required to vertically fit the entire table on the page. |
GetRequiredWidth() | Returns the width required to horizontally fit the entire table (all the columns) on the page. |
GetType() | Gets the Type of the current instance. (Inherited from Object) |
GetVisibleColumnCount() | Returns the number of columns that will be displayed in the current table. |
GetVisibleHeight() | Returns the height of the table that will be seen on the page. |
GetVisibleRowCount() | Returns the number of rows that will be displayed in the current table. |
GetVisibleWidth() | Returns the width of the table that will be seen on the page. |
HasOverflowColumns() | Returns a value indicating if there are columns remaining that will not be drawn to the table. |
HasOverflowRows() | Returns a value indicating if there are rows remaining that will not be drawn to the table. |
SetOverflowTableHeaderColumnCellsTags(Tag[]) | Sets the tags for the overflow table header columns each cell. |
SetOverflowTableHeaderRowCellsTags(Tag[]) | Sets the tags for the overflow table header rows each cell. |
SetOverflowTableHeaderRowTags(Tag[]) | Sets the tags for the overflow table header rows. |
ToString() | Returns a String that represents the current Object . (Inherited from Object) |