Table of Contents

Class BigTable

Namespace
PDFjet.NET
Assembly
PDFjet.dll

A table for large amounts of data, 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

pdf PDF

the PDF.

f1 Font

the header font.

f2 Font

the body font.

pageSize PageSize

the 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

List<Page>

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

color int

the 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

color float[]

the red, green and blue values.

Returns

BigTable

this BigTable object.

SetBottomMargin(float)

Sets the bottom margin.

public BigTable SetBottomMargin(float bottomMargin)

Parameters

bottomMargin float

Returns

BigTable

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

percents float[]

Returns

BigTable

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

columns int[]

the indexes of the fields to draw.

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

page Page

the first page.

y float

the top of the table on it.

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

text string

the text, for example "Seite {page} von {pages}".

font Font

the font, or null for the header font.

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

x float
y float

Returns

BigTable

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

numberOfColumns int

Returns

BigTable

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

padding float

the 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

color int

the 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

color float[]

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

fileName string

the data file.

delimiter string

the field delimiter.

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

header string[]

the header fields, with a field for every column.

rows IEnumerable<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

column int
alignment Alignment

Returns

BigTable