Menu

1 / 3

Invoice PDF page breaks: a row split in half, and the total alone on the last page

DEV Community: css·Dudko Development·1 day ago
#MoyMnExO
#devtocss#devto#dev#break#avoid
Reading 0:00
15s threshold

An invoice template gets tested with five line items. It fits on one page and looks fine. Then a customer orders thirty things, and the PDF comes back with a row cut in half across the page break, or with Subtotal and Tax at the bottom of page one and TOTAL sitting by itself at the top of page two.

It's an old problem. The Stack Overflow question about keeping a table row off a page break has about 240,000 views and was still getting edits in 2025, and the invoice-specific versions of it ( this one , this one ) have no answers at all. A Hacker News comment from October puts the mood well: headless Chrome, Puppeteer, wkhtmltopdf all tried, and "it really feels like it shouldn't be this hard".

It's less hard than it looks once you know which four rules matter. We measured each one rather than repeat the folklore.

The setup

Playwright 1.63 driving Chromium 153 headless, page.setContent() then page.pdf() on US Letter with half-inch margins.…

Continue reading — create a free account

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