Reputation: 33
I have the following situation: I am creating a PDF that contains a table with data with unforseeable, random row count. At the end of every page I put the current page number with iText PdfPageEventHelper
, using the onEndPage
event. This works fine.
The problem: It is possible that the last page is almost empty because after beginning to write a new page there are only a few or only one row from the data table that is left to be written? I want to fill up this region of the last page with empty rows until the bottom of this page.
How am I able to automatically fill up the empty region of the last page with empty rows? I assume can not use:
onEndPage(PdfWriter writer, Document document)
for this purpose?
Upvotes: 3
Views: 2510
Reputation: 1184
You can use getVerticalPosition to determine the space left in the document and use arithmetic to determine the number of rows you will need to create to fill up the page. In your onEndPage method you can create the rows in a table and use writeSelectedRows to write the rows to the document.
Upvotes: 1