To insert a page break using a div
in mPDF, you can use the CSS page-break-after
or page-break-before
property. This property specifies where to insert a page break.
Here's an example of how you can do this:
<div style="page-break-after: always;">
<!-- Content of the first page -->
</div>
<div>
<!-- Content of the second page -->
</div>
In this example, the page-break-after: always;
style will insert a page break after the first div
, so the content of the second div
will start on a new page.
You can also use the <pagebreak />
tag to insert a page break:
<div>
<!-- Content of the first page -->
</div>
<pagebreak />
<div>
<!-- Content of the second page -->
</div>
In this example, the <pagebreak />
tag will insert a page break after the first div
, so the content of the second div
will start on a new page.
Please note that the page-break-after
and page-break-before
properties and the <pagebreak />
tag should be used with care. They can disrupt the flow of your document, especially if you have nested elements. If possible, it's better to let mPDF automatically handle page breaks based on the content of your document.