PdfTable Class
A table, drawn by PdfContentBuilder.DrawTable: columns with fixed, relative or automatic widths, rows of cells whose texts are broken into lines, borders, and header rows drawn again at the top of each page.
public sealed class PdfTableConstructors
| Name | Description |
|---|---|
| PdfTable() | Initializes a new instance of the PdfTable class, without columns. |
| PdfTable(ReadOnlySpan<PdfTableColumn>) | Initializes a new instance of the PdfTable class. |
PdfTable overloads
PdfTable()
PdfTable.csInitializes a new instance of the PdfTable class, without columns.
public PdfTable()PdfTable(ReadOnlySpan<PdfTableColumn>)
PdfTable.csInitializes a new instance of the PdfTable class.
public PdfTable(params scoped ReadOnlySpan<PdfTableColumn> columns)Parameters
columnsReadOnlySpan<PdfTableColumn>- The columns of the table.
Properties
| Name | Description |
|---|---|
| BorderColor | Gets or sets the color of the borders. The default is black. |
| BorderWidth | Gets or sets the width of the borders of the cells, in points, 0 or more: 0 draws no border. The default is 0.5. |
| CellPadding | Gets or sets the space between the borders of a cell and its text, in points, 0 or more. The default is 4. |
| Columns | Gets the columns of the table, from the left. |
| Font | Gets or sets the font of the cells. The default is Helvetica. |
| FontSize | Gets or sets the font size of the cells, more than 0. The default is 10. |
| HeaderRowCount | Gets or sets the number of rows at the start of PdfTable.Rows that are drawn again at the top of each continuation of the table. The default is 0. |
| Hyphenator | Gets or sets the hyphenator of the words that do not fit at the end of a line of a cell, or null to break the lines between the words only. The default is null. |
| LineHeight | Gets or sets the distance between the baselines of two lines of a cell, as a multiple of the font size, more than 0. The default is 1.2. |
| Rows | Gets the rows of the table, from the top: the header rows first. |
| TextColor | Gets or sets the color of the text of the cells, or null for the fill color of the graphics state. The default is null. |
BorderColor
PdfTable.csBorderWidth
PdfTable.csCellPadding
PdfTable.csColumns
PdfTable.csGets the columns of the table, from the left.
public IList<PdfTableColumn> Columns { get; }Property value
Font
PdfTable.csFontSize
PdfTable.csHeaderRowCount
PdfTable.csGets or sets the number of rows at the start of PdfTable.Rows that are drawn again at the top of each continuation of the table. The default is 0.
public int HeaderRowCount { get; set; }Property value
Hyphenator
PdfTable.csGets or sets the hyphenator of the words that do not fit at the end of a line of a cell, or null to break the lines between the words only. The default is null.
public IPdfHyphenator? Hyphenator { get; set; }Property value
LineHeight
PdfTable.csRows
PdfTable.csGets the rows of the table, from the top: the header rows first.
public IList<PdfTableRow> Rows { get; }Property value
TextColor
PdfTable.csMethods
| Name | Description |
|---|---|
| AddHeaderRow(ReadOnlySpan<string>) | Adds a header row after the header rows of the table, and increments PdfTable.HeaderRowCount. |
| AddRow(ReadOnlySpan<string>) | Adds a row at the end of the table. |
| GetColumnWidths(double) | Computes the widths of the columns of the table in a width. |
AddHeaderRow(ReadOnlySpan<string>)
PdfTable.csAdds a header row after the header rows of the table, and increments PdfTable.HeaderRowCount.
public PdfTableRow AddHeaderRow(params scoped ReadOnlySpan<string> cells)Parameters
cellsReadOnlySpan<string>- The texts of the cells, one per column.
Returns
PdfTableRow The row, to set its properties.
AddRow(ReadOnlySpan<string>)
PdfTable.csAdds a row at the end of the table.
public PdfTableRow AddRow(params scoped ReadOnlySpan<string> cells)Parameters
cellsReadOnlySpan<string>- The texts of the cells, one per column.
Returns
PdfTableRow The row, to set its properties.
GetColumnWidths(double)
PdfTable.csComputes the widths of the columns of the table in a width.
Parameters
availableWidthdouble- The width the table is drawn in.
Returns
double[] The width of each column, in points.
Exceptions
ArgumentException- A character of a cell has no glyph in its font.
Remarks
The fixed columns get their width. The automatic columns get the width of their widest paragraph, or less when the table would be wider than availableWidth: down to their widest word, then in proportion to it. The relative columns share the width left. The cells that span several columns do not count in the automatic widths.