When looking at bug reports in Firefox’s printing code, I occasionally see users requesting that we add a checkbox to our print dialog to “just print out the website exactly as I see it laid out on the screen”.
It turns out there are quite a few pitfalls buried in this proposed feature. Not-addressing those pitfalls would make the feature into a bit of a footgun; and it turns out that addressing the pitfalls would largely end up making the feature do what browsers already do for print layout.
Let’s explore this. Pretend you’re a browser developer who’s been tasked to implement this feature: a checkbox labeled “Print the website exactly as it looks in my browser” in the print dialog.
INITIAL VERSION: You add code to take a screenshot of the browser’s viewport (the viewport’s entire scrollable height), and then you draw that directly onto one or more printed pages, pixel-for-pixel.
It’s great! Users are intrigued by this checkbox and start using it, but pre