One HTML file, printed as one page or two
A node sheet for a buoy host is a web page, a one-page PDF and a two-page PDF from the same file. The query string decides which half prints.
The host of the buoy needed a sheet: what the node is, what it draws, what
it needs from the buoy, on one page, with a fuller pre-read behind it. One
HTML file does all three. On the web it is the full page. A script in the
head adds a class to the root when the URL has ?sheet, and that class
hides the second half and the link to the PDF. Headless Chrome prints the URL
twice, once with the query and once without. poppler then reports the page
count and size and lists the embedded fonts, so a build that spills to three
pages or ships a system font fails in the terminal. The same script renders
both PDFs to PNG and screenshots the web page at desktop and phone width.
The footers are page margin boxes, which Chrome has had since 131: an @page
rule with bottom-left and bottom-right content, the right one printing
counter(page) of counter(pages) in the mono face at 8px. Nothing in the
body knows what page it is on.
Keeping the full version on two pages took three passes. Print sizes, tighter table padding, break-inside avoid on the table and the cards. Then a blank third page that no content explained. Chrome adds one for a trailing margin at the end of the document, so in print the last child of main and of every list has no bottom margin, and the root and body have height auto.
The blank page had nothing on it, so nothing in the CSS pointed at it.