dompdf Page break if element is exceeding page height?

startupsmith picture startupsmith · Jan 4, 2012 · Viewed 74.8k times · Source

What is the best way to do page breaks in dompdf?

I have had a look here at the page-break-before css attribute, but it didn't work when I did:

table {page-break-before:auto;}

The page still breaks in the middle of my table.

Is it possible to setup my html/css so that the page will break before the element if the element is going to exceed the page height?

Ideally I would like to divide my html up in to div sections so that each section will start on a new page if it is going to exceed the height of the current page.

Answer

BrianS picture BrianS · Jan 5, 2012

Using page-break-inside: auto; basically says to dompdf "do what you would normally do when breaking pages."

To force a page break before / after your table you would use page-break-before: always; / page-break-after: always;.

To ask dompdf to avoid breaking inside an element you would use page-break-inside: avoid;.