Menu

`@page { size: 4in 6in }` is not enough: what actually decides whether a 4 6 slip prints correctly
πŸ“°

`@page { size: 4in 6in }` is not enough: what actually decides whether a 4 6 slip prints correctly

DEV Community: cssΒ·Honson YoungΒ·8 days ago
#ovkpxMnq
#devtocss#devto#dev#size#print
Long article (994 words) β€” no AI summary yet.
Reading 0:00
15s threshold

I spent a week chasing a bug that turned out not to be a bug in my code.

A packing slip generated in the browser looked correct in the print preview on my machine. A seller printed the same slip on a 4Γ—6 thermal printer and got text that was readable but slightly small, with the bottom row of items clipped. Same HTML, same CSS, different result.

The cause was not the CSS. It was the chain of four places where "4Γ—6" gets decided, and only one of them is under my control.

The four places a page size is set

CSS β€” @page { size: 4in 6in; margin: 0; }

The browser print dialog β€” paper size dropdown and scale ( Fit to page vs 100% )

The printer driver β€” the paper size the driver believes is loaded

The physical roll β€” 4Γ—6 in, with a non-printable dead zone at the edges

If any of the four disagrees, the browser silently scales the content to fit whatever it thinks the paper is. Nothing errors.…

Continue reading β€” create a free account

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