Forum How do I...?

How can I guarantee a certain number of pages?

vhe
Hi!
We've got the problem that we need to create a pdf that can be split in parts with certain content.

Our workflow is:
  • create html
  • create pdf using prince for the whole html
  • store the whole pdf
  • retrieve sections of that html on request.

Until now most of the content was static and the dynamic stuff fit on a set of single pages, so, defining say, four sections as pages 0-5, 6-15, 16-27, 28-56 worked all right.

Now we've got to add text that spans several pages. Sometimes there's enough text to fill, say, 5 pages in a section and sometimes there only text for 3 pages.

In order to still be able to split the generated pdf at say, pages 5, 15 and 27 and get the right content in, I need to guarantee that the sections have the correct number of pages. Ideally, by having price insert blank pages in certain places in the document until the correct number of pages is achieved.

Do you have any idea how I can do that?

Alternatively, is it possible to embed some tags into the html an have prince split the generated pdf at the sections?

For performance reasons it is, unfortunately, impossible to render the sections independently and combine them later.

Lots of Greetings!
Volker

Edited by vhe

mn4367
One idea is to use the Box Tracking API. This would enable to see on which page certain elements appear. But you'll end up with processing the source document twice:
  • Process the source document and track the page numbers.
  • Insert page breaking elements in the source document (and maybe save it as the new source), based on the information gathered in step 1.
  • Process the source document again.
vhe
Thanks a lot but in the system, unfortunately we don't have the time to do the rendering twice. :-(
Otherwise we could have rendered the individual sections and then assembled the pdf as required.