How to detect pagebreak in Prince PDF?

1.4k Views Asked by At

I have a generated 100 pages long document with dozens of sections, headers and varying text + image content. There are user inserted pagebreaks as well as injected pagebreaks, but most of the text runs from page to page.

Something that is driving me crazy is that I cannot detect if an element is the first or the last on the page.

For example my text-container div has bottom and top margin of 10 mm. If pagebreak happens just before it, it should have 0 top margin. But since I have no way of detecting Prince automated pagebreaks, text-containers have 10mm extra top margin on some pages.

(this is an example only, the real situation is a little more complex)

Is there ANY way to detect what Prince is doing to flowing content?

1

There are 1 best solutions below

0
On

First you need to set the Page height, unless your text will go out from the page. and after set page-break-after: always in page container class. then it will works.