Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DOMpdf, adding a new page to PDF

Tags:

php

dompdf

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.

like image 857
Kitalpha Avatar asked Mar 30 '14 17:03

Kitalpha


People also ask

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

How do I change the page size of a PDF in Dompdf?

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.

Can we use bootstrap in Dompdf?

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.

How do I create a header and footer in Dompdf?

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


2 Answers

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

like image 52
BrianS Avatar answered Sep 26 '22 22:09

BrianS


Just an example for BrianS's answer:

CSS

.page_break { page-break-before: always; } 

HTML

<div class="page_break"></div> 
like image 39
cottton Avatar answered Sep 26 '22 22:09

cottton