I am investigating a replacement for iText and have been looking at the API and example code for PdfBox. I am slightly confused by its useage though, it seems I need to manually create the page objects which implies I need to know the number of pages beforehand or at least work out when its time to create a new page.

I generally use PDF generation for reports based on user configurable parameters which call stored procedures which can return varying amounts of data.

My question is quite simple, is it down to me to try and work out how much data will fit onto a page and create the pages programmatically?

The API seems to state that each page object represents a single page. From my experience of iText I do not need to worry about this, I simply write my data to the document and the pages are created for me based on the content I am placing into it.

有帮助吗?

解决方案

I recently made the switch from iText to PDFBox and ran into a similar issue. I asked this question and eventually worked out what I needed to do to generate reports with an unknown number of pages.

This model works well for generating reports containing lines of data generated from a ResultSet...though that's the only way I've been using it thus far. I may run into limitations, but for now, it's getting the job done.

And I guess I should state that I am still laying out each page manually, but this method does at least generate my pages dynamically depending on the number of results that return.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top