Menu

Playwright page.pdf(): missing backgrounds, a 0.7 pt header and @page sizes, each measured
📰

Playwright page.pdf(): missing backgrounds, a 0.7 pt header and @page sizes, each measured

DEV Community: css·CurlShot·9 days ago
#f61FE8nh
#devtocss#devto#dev#ababab#size
Reading 0:00
15s threshold

I wanted page.pdf() to produce a report with a page-number footer, a coloured banner and A4 pages. Four things behaved differently from what I expected, so I measured each one. I read the PDFs back with pdf.js, which gives text size, position, fill colours and page size, so nothing below was judged by eye.

The short version:

Without printBackground: true the background colour is dropped. White text on it stays, on a white page.

A header or footer template without a font-size is drawn at about 0.7 pt. The text is in the PDF and nobody can read it.

A CSS @page { size } is ignored unless preferCSSPageSize: true , but its orientation is not. A landscape @page turned my format: 'A4' into a landscape page.

break-inside: avoid stops cards from splitting across pages. A <thead> repeats on every page, a plain <tr> header does not.

Setup

Playwright 1.63.0 (Chromium 153.0.8010.12), pdfjs-dist 6.5.438, Node v24.22.2, Linux, 2026-11-06.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.