Please read chapter 4 of my book or browser the documentation that is abundant on the iText site.
By default, table rows aren't split. iText will try to add a complete row to the current page, and if the row doesn't fit, it will try again on the next page. Only if it doesn't fit on the next page, it will split the row. This is the default behavior, so you shouldn't be surprised by what you see in your application.
You can change this default behavior. There's a method that will allow you to drop content that doesn't match (this is not what you want) and there's a method that will allow you to split rows when they don't fit the current page (this is what you want).
The method you need is used in the HeaderFooter2 example:
PdfPTable table = getTable(...);
table.setSplitLate(false);
By default, the value of setSplitLate()
is true
: iText will split rows as late as possible. By changing this default to false
, iText will split rows immediately.