Class BigTable
A table of plain rows of any length, a statement, a list or an export: every row has one style, and a field too wide for its column is cut short, or, with SetWrapText, wraps onto more lines, the row as tall as its tallest field. For drawables in cells, spanned cells or page totals, use Table. The rows are read row by row from a delimited text file or from an IEnumerable. Each page is written as soon as it is full, so the memory stays flat however many rows there are. A PDF/UA document holds no more than that either: the table is tagged as a table, and the structure elements of a page are written with it. What is left is one cross-reference entry for each of them, which every object of a PDF has.
public class BigTable
- Inheritance
-
BigTable
- Inherited Members
Constructors
BigTable(PDF, Font, Font, PageSize)
Creates a table with the specified fonts and page size.
public BigTable(PDF pdf, Font f1, Font f2, PageSize pageSize)
Parameters
pdfPDFthe PDF.
f1Fontthe header font.
f2Fontthe body font.
pageSizePageSizethe page size, for example Letter.PORTRAIT.
Methods
Complete()
Draws the rows, then the vertical lines, with the footer on every page. The pages are added to the PDF as they are drawn, so the document does not hold them all. Call it after the location, the bottom margin and the table data have been set. A table without data draws nothing.
public void Complete()
GetPages()
Returns the pages, which Complete has already added to the PDF.
public List<Page> GetPages()
Returns
SetBorderColor(int)
Sets the color of the lines between the rows and the columns and around the table. Color.transparent leaves the lines out.
public BigTable SetBorderColor(int color)
Parameters
colorintthe color as a 0xRRGGBB value, for example Color.gray.
Returns
- BigTable
this BigTable object.
SetBorderColor(float[])
Sets the color of the lines between the rows and the columns and around the table from its red, green and blue values from 0 to 1. null leaves the lines out.
public BigTable SetBorderColor(float[] color)
Parameters
colorfloat[]the red, green and blue values.
Returns
- BigTable
this BigTable object.
SetBorderWidth(float)
Sets the width of the lines between the rows and the columns and around the table, 0.5 points unless set, as every line PDFjet draws by default (9.1.9); 0 is the thinnest line of the device, a pixel on a screen, faint or gone in print. A negative width, or one that is not a number, is recorded on the PDF as misuse, and the width is left as it was.
public BigTable SetBorderWidth(float width)
Parameters
widthfloatthe width, 0 or more.
Returns
- BigTable
this BigTable object.
SetBottomMargin(float)
Sets the bottom margin.
public BigTable SetBottomMargin(float bottomMargin)
Parameters
bottomMarginfloat
Returns
SetColumnWidths(params float[])
Gives the columns, in the order SetColumns draws them, their widths in points, as Table's cells have them, the padding of each side in them; the table is as wide as their sum. A field wider than its column is cut to fit it, its text ending in " ...", or wraps in it with SetWrapText. It takes the place of SetColumnWidthsInPercent, as that takes the place of it. Call it after SetColumns or SetNumberOfColumns: widths that are not one for each column, or one that is negative or not a number, are refused.
public BigTable SetColumnWidths(params float[] widths)
Parameters
widthsfloat[]the width of each column, in points.
Returns
- BigTable
this BigTable object.
SetColumnWidthsInPercent(params float[])
Gives the columns, in the order SetColumns draws them, their percentages of the width of the table, the width of the page less the margin of SetLocation on each side, as Table's SetColumnWidthsInPercent does; percentages that do not add up to 100 are shares of it. A field wider than its column is cut to fit it, its text ending in " ...". Without them each column is as wide as its widest field. Call it after SetColumns or SetNumberOfColumns: percentages that are not one for each column, or one that is negative or not a number, are refused.
public BigTable SetColumnWidthsInPercent(params float[] percents)
Parameters
percentsfloat[]
Returns
SetColumns(params int[])
Sets the fields of every row that the table draws, by their index from 0, in the order they are drawn, so SetColumns(3, 0, 11) draws the fourth field, then the first, then the twelfth. The indexes pick the header fields the same way. A row without a field for every index is skipped. Call it before SetTableData; SetTextAlignment counts the columns as they are drawn.
public BigTable SetColumns(params int[] columns)
Parameters
columnsint[]the indexes of the fields to draw.
Returns
- BigTable
this BigTable object.
SetFallbackFonts(Font, Font)
Sets the fonts that draw the characters the header's font and the rows' font do not have, such as Korean or Chinese in a table of a Latin font: each character in the font of its row if it has it, else in the fallback font, and measured so. A null font is none, as unless set. Call it before SetTableData, which measures the columns.
public BigTable SetFallbackFonts(Font header, Font rows)
Parameters
headerFontthe fallback font of the header's font, or null.
rowsFontthe fallback font of the rows' font, or null.
Returns
- BigTable
this BigTable object.
SetFirstPage(Page, float)
Starts the table on a page of the PDF that has other content above it, such as a heading, at y on that page. The next pages are new, and the table starts on them at the y of its location. The page is one that new Page(pdf, pageSize) has added to the PDF, and nothing is drawn on it after the table. When the header and the first row do not fit on the page above its bottom margin, the table starts on a new page instead, and draws nothing on it.
public BigTable SetFirstPage(Page page, float y)
Parameters
Returns
- BigTable
this BigTable object.
SetFooter(string, Font)
Sets the footer drawn at the bottom of every page, centered. In the text, {page} stands for the number of the page and {pages} for the number of pages. The footer is "Page {page} of {pages}" in the header font by default. A null or empty text leaves the footer out.
public BigTable SetFooter(string text, Font font)
Parameters
textstringthe text, for example "Seite {page} von {pages}".
fontFontthe font, or null for the header font.
Returns
- BigTable
this BigTable object.
SetFooterFontSize(float)
Sets the size of the footer's text, so that it can be smaller than the table's with the same font. It is the size of the footer's font unless it is set.
public BigTable SetFooterFontSize(float size)
Parameters
sizefloatthe size in points, more than 0.
Returns
- BigTable
this BigTable object.
SetFooterOffset(float)
Sets the distance from the bottom of the page to the baseline of the footer, as Page.AddFooter takes it, so that the footer can sit at the bottom margin. It is the ascent of the footer's font unless it is set, the footer just above the edge of the page.
public BigTable SetFooterOffset(float offset)
Parameters
offsetfloatthe distance in points, 0 or more.
Returns
- BigTable
this BigTable object.
SetHeaderColor(int)
Sets the background color of the header row, on every page. Unless it is set, the header is shaded as the first of every other row, in the shading color. Color.transparent goes back to that.
public BigTable SetHeaderColor(int color)
Parameters
colorintthe color as a 0xRRGGBB value, for example 0xE6E6E6.
Returns
- BigTable
this BigTable object.
SetLocation(float, float)
Sets the location of the top left corner of this table.
public BigTable SetLocation(float x, float y)
Parameters
Returns
SetNumberOfColumns(int)
Sets the number of columns in this table: the first fields of every row, in their order. It is the same as SetColumns(0, 1, ... numberOfColumns - 1).
public BigTable SetNumberOfColumns(int numberOfColumns)
Parameters
numberOfColumnsint
Returns
SetPadding(float)
Sets the space between the text of a column and the lines on its left and right. It is 2 points by default.
public BigTable SetPadding(float padding)
Parameters
paddingfloatthe padding.
Returns
- BigTable
this BigTable object.
SetShadingColor(int)
Sets the color of every other row, starting with the header. Color.transparent turns the shading off.
public BigTable SetShadingColor(int color)
Parameters
colorintthe color as a 0xRRGGBB value, for example Color.lightgray.
Returns
- BigTable
this BigTable object.
SetShadingColor(float[])
Sets the color of every other row, starting with the header, from its red, green and blue values from 0 to 1. null turns the shading off.
public BigTable SetShadingColor(float[] color)
Parameters
colorfloat[]the red, green and blue values.
Returns
- BigTable
this BigTable object.
SetTableData(string, string)
Reads the data file to set the column widths, the column alignment and the header fields. The file is read as UTF-8. Its first line with a field for every column is the header, and the lines after it are the rows. A quoted field is read as RFC 4180 reads it, so a delimiter inside one is text, and a line break inside one goes on to the next line of the file and is drawn as a space.
public BigTable SetTableData(string fileName, string delimiter)
Parameters
Returns
- BigTable
this BigTable object.
SetTableData(string[], IEnumerable<string[]>)
Sets the column widths, the column alignment and the header fields from rows that are not in a file: the results of a query, or a list of objects. The rows are enumerated twice, once here to measure the columns and once by Complete to draw them, and neither keeps them, so an IEnumerable that runs the query again, or maps the objects to fields as it goes, keeps the memory flat. A row without a field for every column is skipped, as a short line of a file is, and a line break in a field is drawn as a space.
public BigTable SetTableData(string[] header, IEnumerable<string[]> rows)
Parameters
headerstring[]the header fields, with a field for every column.
rowsIEnumerable<string[]>the fields of each row, in the order they are drawn.
Returns
- BigTable
this BigTable object.
SetTextAlignment(int, Alignment)
Sets the text alignment of the specified column, which is one of the columns of the table. Call it after SetTableData, which makes the columns: a column that the table does not have is refused.
public BigTable SetTextAlignment(int column, Alignment alignment)
Parameters
Returns
SetTopLine(bool)
Sets whether the line above the header is drawn, on every page. It is unless set; without it a table of lines under its rows alone, with SetVerticalLines(false), looks as a Table of cells with a bottom border alone.
public BigTable SetTopLine(bool topLine)
Parameters
topLineboolfalse to leave the line above the header out.
Returns
- BigTable
this BigTable object.
SetVerticalLines(bool)
Sets whether the vertical lines between the columns and at the sides of the table are drawn. They are unless set; without them the table has only the lines between its rows, a lighter look for a long table.
public BigTable SetVerticalLines(bool verticalLines)
Parameters
verticalLinesboolfalse to leave the vertical lines out.
Returns
- BigTable
this BigTable object.
SetVerticalPadding(float)
Sets the space between the text of a row and the lines above and below it, the header row's too. It is 0 by default, and a row is as tall as its font; a table with it takes more pages.
public BigTable SetVerticalPadding(float verticalPadding)
Parameters
verticalPaddingfloatthe padding, 0 or more.
Returns
- BigTable
this BigTable object.
SetWrapText(bool)
Sets whether a field too wide for its column wraps onto more lines, at its spaces, a word longer than its column broken between its characters, rather than being cut short; a row is then as tall as its tallest field. The columns keep the widths of SetColumnWidthsInPercent, or, without them, their widths, as wide as their widest fields, when the table fits its page; when it does not, the narrow columns keep theirs and the others share what is left equally. A row that does not fit what is left of a page starts the next; one taller than a whole page is cut at the lines that fit, ending in " ...", its cell keeping the whole of its text. The rows are read once more to count the pages, three times in all, and the memory stays flat. It is off unless set, and the table is drawn as before.
public BigTable SetWrapText(bool wrap)
Parameters
wrapbooltrue for the fields to wrap.
Returns
- BigTable
this BigTable object.