DOMpdf, adding a new page to PDF

2020-06-07 04:29发布

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.

标签: php dompdf
4条回答
一夜七次
2楼-- · 2020-06-07 04:41

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

查看更多
何必那么认真
3楼-- · 2020-06-07 04:51

If the other answer doesn't work for you (as it is for me), you can add a CSS class :

.page { width: 100%; height: 100%; }

and encapsulate every "page" in an element with this class. Not the prettiest way, but it does the job.

查看更多
ら.Afraid
4楼-- · 2020-06-07 04:53

All answers presented here will make DomPDF to add a blank page to the end of the PDF file. Here is how to fix that:

CSS:

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

HTML:

<div class="page_break"></div>
查看更多
小情绪 Triste *
5楼-- · 2020-06-07 05:08

Just an example for BrianS's answer:

CSS

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

HTML

<div class="page_break"></div>
查看更多
登录 后发表回答