Forum How do I...?

Avoiding empty pages

mark_anderson_us
Hi All

I want to try and prevent a group header and footer being orphaned. Works great until I have a really long section (see attached).

This is a packing list and the cartons are group by job no, so there can be multiple groups per document, each with it's own header and footer

for the group header I have: <tr style="page-break-after: avoid;">
for the detail rows, I have <tr style="page-break-after: avoid;">
for the group footer, I have: <tr class="totals" style="page-break-after: avoid;">

What's the best way to stop the group header or footer being orphaned?


TIA
Mark
  1. Page-break.jpg31.7 kB
mikeday
Perhaps just use page-break-after on the header and page-break-before on the footer and allow the detail rows to break?

The tricky situation is if you want small groups to be moved to the next page instead of broken, but large groups to be broken; this would require counting the number of rows in the group and applying different CSS for those beyond a certain size.
mark_anderson_us
thanks mike. I'm assuming you switched your before and after in your suggestion?

I was trying to keep whole groups together. I could make sure that I kept at least X rows with the header, and that X there were at least x=1 rows, so the footer isn't orphaned, but what I really want to do is figure out how many rows and how many would fit on remaining space, so I can determine an optimum split

mikeday
I think that will require JavaScript and a two-pass approach.