Forum How do I...?

Problem with page break

zambadu
Hi,
I have attached a HTML file and the outputing PDF, I'm unable or to stupid to get the page break work probably. The expected behavior was, that prince automatically breaks the content an generate as much pages as needed. The amount of pages in PDF seems to be correct, but the content from the .page3-div is only shown on first page, the others are empty. So maybe the page-break breaks the surrounding div and the content is losing its formatting from css?

Thanks for your help.
  1. 20210430131637doc608bee01967b097a02308402.html42.0 kB
    HTML
  2. 20210430131637doc608bee01967b097a02308402.pdf1.4 MB
    Output pdf

Edited by zambadu

mikeday
It's a complicated document, commenting out all the inline style="..." attributes makes a lot more of the content show up, are they applying absolute positioning or fixed heights?
zambadu
Hi Mike,
yes it is a bit complicated, as we have to show the HTML in our Frontend Editor for the user to edit and on the other hand make it work for Prince.

The Problem here is, that we normally have fixed page height in our editor and some mechanics to prohibit that the user can add more content then space is available on the page.

But in this case we have a document with 8 pages in our editor, and one of these pages should be endless, so the user can add content as much as he wants. Then we want to generated pages in the correct size with prince. So normally the content is positioned absolute, but here I think it will better work if it is relative. Am I getting this right?

So short: Page 3 should be split up by prince in as many pages as it needs to fit the content on the @page size. The other pages have fixed heights and are working as expected.

Edited by zambadu

mikeday
Right, absolutely positioned blocks cannot be split across multiple pages, and nor can inline-blocks, so you may also need to check for "display: inline-block" if extra content is going missing.
zambadu
Ok, I managed to get the content split across multiple pages, next problem I trying to resolve, is a page-break before a div with a special class name.
In the example above the article with the class "firmen-ubs" I have append to the css the break-before: always, but it doesn't break the page. Is it because the div is to nested in the structure?

Edit: ok "break-before: page" does the trick. Nevermind. :)

Edited by zambadu

zambadu
By the way it seems to be, that the css rule: "top: unset" is ignored by prince.

Edited by zambadu

mikeday
Right, Prince does not support the special "unset" value yet.
zambadu
Ok, thanks for your answers.

Last question (maybe :) ):

Is there a way to avoid double page breaks? For example if the content breaks the page in the flow, and the first element of the new page is the headline with the break-before, I get a double page break, from the flow and from the headline. Are there any mechanics to avoid this?
I have tried some fancy css selector combinations, but no luck with them so far.

Edited by zambadu

mikeday
So does it leave a completely blank page before the heading, or do you want the heading to immediately follow the previous content instead of breaking if the previous content was more than one page?
zambadu
Yes, it does leave a blank page before, the heading should always begin a new page.
I have attached an example.
  1. 20210504163921doc609148d320bc7c2ab1284aa2.pdf1.5 MB
    Sample PDF
mikeday
There are two things that can cause this, one is a long element with a fixed height so that it takes up some of the apparently blank page, the other is an "empty" element containing white space or similar that ends up on the apparently blank page, causing another page break before the heading.