PDF layout
Print CSS that paginates cleanly, headers and footers with page numbers, and password-protected PDFs.
Print CSS tips
A starting point for documents that paginate cleanly. Send it with "media": "print":
@page { size: A4; margin: 16mm 14mm; }
/* Keep colours and backgrounds exactly as designed. */
html { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
/* Start each chapter on a new page; never split these blocks. */
.chapter { break-before: page; }
figure, tr, .card { break-inside: avoid; }
/* Keep headings with the paragraph that follows. */
h1, h2, h3 { break-after: avoid; }
/* Repeat table headers on every page. */
thead { display: table-header-group; }
/* Fewer orphaned lines at page ends. */
p { orphans: 3; widows: 3; }- Use
@pageand@media printCSS with"media": "print"for print-specific layouts. - Control page breaks with
break-before,break-afterandbreak-inside: avoid. - Web fonts (Google Fonts or
@font-face) work; they are loaded before printing. - Content drawn by JavaScript after load needs
waitFor. URLs are scrolled through first, so images that load on scroll appear; for HTML that does this, setlazyLoadto true. - Cookie banners on URLs are accepted first, so they don't cover the page. Set
acceptCookiesto false to keep them. - Pages can only reach the public internet: local, private and cloud-internal addresses are blocked.
- With
singlePage(Basic, Plus, Pro and Enterprise), very tall pages are capped at 200 inches, the largest page Acrobat opens.
Encryption
BasicPlusProEnterpriseSetting userPassword or ownerPassword encrypts the PDF with AES-256. Without the owner password, readers may only do what permissions allows (default: print).
{
"html": "<h1>Payslip</h1>",
"userPassword": "opens-the-file",
"ownerPassword": "lifts-restrictions",
"permissions": ["print"]
}