Keep up to date with Gravity PDF

The PDF software, mPDF, introduces a custom HTML tag called <pagebreaks/> which you can use to create new pages in your PDF. It goes hand in hand with the @page CSS property, and when used together they give you precise control over the look and feel of each page of your document.

You can explicitly add page breaks to your PDF using the <pagebreaks/> HTML tag. And while there are a large number of attributes this tag supports – like page margins and sheet size – we prefer to forgo them and use @page instead (discussed here).

We briefly touched on using @page when discussing headers and footers. This special CSS property can be used to control margins, headers/footers and backgrounds:

@page {
margin: 3mm;
background: #EEE;
}

However, it can also be used to target specific pages in your PDF document using Named @page selectors in conjunction with the <pagebreaks> tag. When using named @page selectors you can also control the paper size and orientation.