Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dompdf Page break if element is exceeding page height?

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.

like image 348
startupsmith Avatar asked Jan 04 '12 07:01

startupsmith


People also ask

How to use page-break in dompdf?

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; .

How do I create a dynamic page-break in HTML?

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.

How do you do a page-break in CSS?

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.

How do I add a page in Dompdf?

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; .


2 Answers

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;.

like image 136
BrianS Avatar answered Sep 18 '22 21:09

BrianS


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?

like image 42
andreas-supersmart Avatar answered Sep 18 '22 21:09

andreas-supersmart