Reputation: 1533
I would like to know if there is a way to detect if the last row in a table is exceeded the page and if so write it on the next page and write the table header to the next page as well.
I don't want to use table.KeepTogether = true;
because if the table is longer than 1 page it just move the exceeded rows to the next page without the header.
The table does not start from the beginning of the page, so using the onStartPage()
event is not good.
This is how it looks when the table is exceeded 1 page:
Hope that someone can help me here. Thanks!
Upvotes: 1
Views: 1128
Reputation: 77528
Seems like you want the repeating header functionality as described in the HeaderFooter1 example. For the corresponding C# examples, see http://tinyurl.com/itextsharpIIA2C04
For instance, if table
is an instance of the PdfPTable
class and the first row needs to be repeated when the table is split in two, then you need to add this line:
table.HeaderRows = 1;
Now the first row will be repeated automatically.
Upvotes: 2