Class Table
A table DOM that can be rendered through DrawTable(Table, PdfPoint).
Inherited Members
Namespace: DRIT.Pdf.Content
Assembly: DRIT.Pdf.dll
Syntax
public sealed class Table
Properties
Border
Gets the table border.
Declaration
public TableBorder Border { get; }
Property Value
| Type | Description |
|---|---|
| TableBorder |
ColumnAdjustment
Gets or sets the column width adjustment strategy.
Declaration
public TableColumnAdjustment ColumnAdjustment { get; set; }
Property Value
| Type | Description |
|---|---|
| TableColumnAdjustment |
ColumnWidths
Space-separated widths in points or percentages (for example: "100 120 80" or "30% 70%").
Declaration
public string ColumnWidths { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
DefaultCellBorder
Gets the default border applied to cells without an explicit border.
Declaration
public TableBorder DefaultCellBorder { get; }
Property Value
| Type | Description |
|---|---|
| TableBorder |
DefaultCellPadding
Gets or sets the default cell padding. Default is 2 points on all sides.
Declaration
public TablePadding DefaultCellPadding { get; set; }
Property Value
| Type | Description |
|---|---|
| TablePadding |
IsInNewPage
Gets or sets whether this table starts on a new page.
Declaration
public bool IsInNewPage { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Margin
Gets or sets the table margin around the rendered grid area.
Declaration
public TableMargin Margin { get; set; }
Property Value
| Type | Description |
|---|---|
| TableMargin |
RepeatingColumnsCount
Gets or sets the number of columns to repeat at the left of each page.
Declaration
public int RepeatingColumnsCount { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
RepeatingRowsCount
Gets or sets the number of rows to repeat at the top of each page.
Declaration
public int RepeatingRowsCount { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Rows
Gets the row collection for this table.
Declaration
public TableRowCollection Rows { get; }
Property Value
| Type | Description |
|---|---|
| TableRowCollection |
Methods
GetHeight(double)
Gets the total table height for the given available width.
Declaration
public double GetHeight(double availableWidth = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| double | availableWidth | The available width for column width calculations. Default is 0. |
Returns
| Type | Description |
|---|---|
| double | The total table height in points. |
GetRowsThatFit(double, double, int)
Gets the number of rows that fit within the specified height.
Declaration
public int GetRowsThatFit(double availableHeight, double availableWidth = 0, int startRowIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| double | availableHeight | The available height in points. |
| double | availableWidth | The available width for column width calculations. Default is 0. |
| int | startRowIndex | The zero-based index of the first row to check. Default is 0. |
Returns
| Type | Description |
|---|---|
| int | The number of rows that fit, or 0 if none fit. |
GetWidth(double)
Gets the total table width for the given available width.
Declaration
public double GetWidth(double availableWidth = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| double | availableWidth | The available width for column width calculations. Default is 0. |
Returns
| Type | Description |
|---|---|
| double | The total table width in points. |
ImportDataTable(DataTable, bool, int, int, int, int, bool)
Imports data from a DataTable into this table's rows.
Declaration
public void ImportDataTable(DataTable dataTable, bool includeHeader, int startRow = 0, int startColumn = 0, int rowCount = 2147483647, int columnCount = 2147483647, bool isHtmlText = false)
Parameters
| Type | Name | Description |
|---|---|---|
| DataTable | dataTable | The source data table. |
| bool | includeHeader | Whether to create a header row from column names. |
| int | startRow | The zero-based source row index to start from. Default is 0. |
| int | startColumn | The zero-based source column index to start from. Default is 0. |
| int | rowCount | The number of rows to import. Default is all remaining rows. |
| int | columnCount | The number of columns to import. Default is all remaining columns. |
| bool | isHtmlText | Whether to convert HTML to plain text. Default is false. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
| ArgumentOutOfRangeException | Thrown when startRow, startColumn, rowCount, or columnCount is negative. |
SetColumnWidths(params double[])
Sets column widths explicitly as point values.
Declaration
public void SetColumnWidths(params double[] widths)
Parameters
| Type | Name | Description |
|---|---|---|
| double[] | widths | The widths for each column in points. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
| ArgumentOutOfRangeException | Thrown when any width is not positive. |