Is it possible to add a new page in DOMpdf? Similar to mPDF AddPage(); functionaly. I can't seem to find anything in the documentation, is there any work around to this?
I can't seem to find anything in the documentation.
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; .
By default it's going to render on 'US Letter', you can change this by using: $dompdf->set_paper(DEFAULT_PDF_PAPER_SIZE, 'portrait'); You can use 'letter', 'legal', 'A4', etc.. With dompdf 0.6 you can also use the CSS @page rule to set your page size/orientation.
dompdf's CSS support is still a little lacking for something as complex as Bootstrap. You can get a basic design working, but more complicated designs are not likely to produce the desired results. If you provide a sample of the HTML we can try to tweak the CSS to get better results.
// your dompdf setup $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); // add the header $canvas = $dompdf->get_canvas(); $font = Font_Metrics::get_font("helvetica", "bold"); // the same call as in my previous example $canvas->page_text(72, 18, "Header: {PAGE_NUM} of {PAGE_COUNT}", $font, 6, array(0 ...
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;
.
Just an example for BrianS's answer:
CSS
.page_break { page-break-before: always; }
HTML
<div class="page_break"></div>
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