I am iterating over a list of objects. With each iteration I build and populate a table which contains the content of a single page.
I am using CSS to add a page break after each table.
table { page-break-after: always; }
This works great, except that I am always getting a blank last page. Which I assume is due to the last table iteration applying a page break.
I have tried.
table { page-break-after: always; }
table { page-break-after: auto; }
table { page-break-after: left; }
table { page-break-after: right; }
However, I always get that blank last page.
Is there another method of inserting page breaks that would not create the blank last page?
Or maybe some way to detect if is the last iteration and not insert the last page break?
You could add this:
table:last-of-type {
page-break-after: auto
}
Or maybe
body > *:last-child {
page-break-after: auto
}
I'm using ruby to create pages. I created different css to breaking and no breaking.
#publication_no_break{
/* stuff here */
page-break-after: avoid;
}
#publication_break{
/* stuff here */
page-break-after: always;
}
And on code I count every page I need to print and
<% if page != total_pages %>
< .... .... id="publication_break" >
<% else %>
< .......... id="publication_no_break">
<% end %>
You can try something like this in any language you're coding.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With