Forum How do I...?

Not quite right widow/orphan controls

abaker87
We are using a <div> to append a signature block and keep it on the same page with the last paragraph in our file.

So (briefly, full sample attached):
<p>
    Short paragraph.
</p>
<p>
    Long Paragraph.
</p>
<div class='signature-block-container'>
   Signed by Joe Smith
</div>



For p tags we are using: (line 77 in sample.html)
widow: 3;
orphans: 2;

and we have added a rule to the signature block:
p + .signature-block
page-break-before: avoid

With a significantly long paragraph, what I expect to happen is for the long paragraph to be split between two pages as it has way more than 5 (3 widow, 2 orphan) lines, and the signature block to be on the same page as the second half of that long paragraph.

That widow/orphan control works just fine before we add a rule to prevent page break before a signature block. Once this 'page-break-before: avoid' is in there, the entire (long) paragraph is pulled to the next page along with the signature.

Attached is the base html file (sample.html), a css file we pass to prince (print_specific.css) and the output pdf file (sample.pdf).

Any thoughts on what may be happening here?



  1. print_specific.css6.5 kB
  2. sample.html9.8 kB
  3. sample.pdf23.2 kB
mikeday
This looks like a limitation in the way that Prince handles page-break-before/after: avoid, where the entire element will be moved instead of split. We will try to fix this in a future release of Prince, but in the meantime I'm not sure how to avoid this problem automatically.
abaker87
Thanks for looking into it. Yeah, I guess we are running into a more complex scenario than prince will handle properly. And it should happen very infrequently as it is.

Thanks agian.
joeh
I'm running into this same issue in Prince 12, so I'm guessing this hasn't been fixed yet, unless I'm missing something. Is there any way to work around this?
mikeday
At the moment this would require detecting the situation after typesetting by running some JavaScript to inspect the box tree, then rerunning Prince with altered CSS in a two-pass process. It's a little complicated, hopefully we can fix the underlying issue in the future.