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.
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; .
page-break-before: auto instead of . page-break-before: always. The "auto" will break the page only if the contents are at the end if the page, this will prevent breaking the page and leaving a lot of blank space.
The page-break-after property adds a page-break after a specified element. Tip: The properties: page-break-before, page-break-after and page-break-inside help to define how a document should behave when printed. Note: You cannot use this property on an empty <div> or on absolutely positioned elements.
dompdf takes care of paging automagically. If you want to force a page break you can do so by styling an element with page-break-before: always; or page-break-after: always; .
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;
.
You might make quick tests with this online debugger - i finally found my pagebreak and margin issue after days of testing.
Excursus: Did anyone install a debug environment on the development/production environment and can point me to any documentation or tutorial?
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