Page breaks only if needed
-
I have a report that's being output using phantom-pdf and I want to ensure that if a table is going to have a page break that it will start on a new page (if it then has page breaks in it subsequently I'm okay with that)
Because the items above it will be variable length, I can't add a consistent number of blank lines to force it to the next page.
I have tried using the
style="page-break-after:auto"...
in a div around the table (and it's header. also tried adding the style just to table) which doesn't seem to help.:always
unfortunately always starts it on a new page even if the first and second table would have fitted on the one pageHopefully there's a solution
-
The css solution is to use
page-break-inside:avoid
. See the chrome demo
https://playground.jsreport.net/w/anon/iDp6v2lIThe default phantomjs doesn't support this, however here seems to be a workaround
https://github.com/ariya/phantomjs/issues/10638#issuecomment-20186253