I have the following situation creating a PDF with iTextSharp.
I have some pages that contains some tables. It could be happen that a table begin in a page and keep on in the following page.
I want to know if, when a table keep on in the following page, is it possible to "replicate" the table header in the new page.
For example if a table begin in the page 1 and keep on in the table 2 I want have the following situation:
The table begin with its header in page 1 and keep on in page 2 so at the beginning of page 2 I have again the table header. Something like happen with table in Microsoft Word.
Can I do something like it?
Tnx
You are asking for something called "repeating table headers". You can find some examples on the official iText site on the page for the keyword PdfPTable > header rows.
For instance, if you have an instance of PdfPTable
named table
, and the first two rows you've been adding are actually the header, then you can define them as header rows like this:
table.setHeaderRows(2);
If you want the C# version of the examples taken from my book, you can find them here: http://tinyurl.com/itextsharpIIA2C04
These examples show you that the syntax in C# is slightly different, but still easy:
table.HeaderRows = 1;
In this line, we tell the table
that the first row is a header row that should be repeated.