Re: Page break if element won't fit on the page

6,991 views
Skip to first unread message

BrianS

unread,
Jul 24, 2012, 2:45:52 PM7/24/12
to dom...@googlegroups.com
You can style elements with page-break-inside: avoid; to tell dompdf to avoid using a page break inside an element. Implementation of this declaration isn't perfect. It currently doesn't work on table elements. But if you style a container div it should work ok. Something like this:

<div style="page-break-inside: avoid;">
<table>...</table>
</div>

The other problem is more important to take note of. If you style an element this way and it's larger than one page then dompdf could enter an infinite loop attempting to render the element. This is one of the issues we're trying to correct for the stable 0.6.0 release. I don't think you'll have an issue for this particular setup, but it's something to keep in mind.


On Monday, July 23, 2012 5:56:51 PM UTC-4, Evan Anderson wrote:
Is there the ability to define when a page break happens based on wether of not the element would span a page break? For example, if a table was going to be split across 2 pages, then insert a page break before the table is rendered. I am aware that I could add page breaks for every table, but thats not the ideal solution as this would create a new page for every table regardless of its size and position within the content.

Much appreciated,
- Evan

Evan Anderson

unread,
Jul 24, 2012, 2:48:36 PM7/24/12
to dom...@googlegroups.com
Thanks Brian, I actually just found this this morning as well and have been fooling around with it, still having some difficulties as its breaking in a figure when I have that the page-break-inside: avoid defined in the CSS doc, but I'm narrowing it down. Thanks for the response.

Mk Cheng

unread,
Nov 1, 2018, 9:14:38 PM11/1/18
to dompdf
I have used this method, but my element larger than one page and now the content will infinitely loop. If i using Version 0.8.0, this problem how to solve? 
Reply all
Reply to author
Forward
0 new messages