Live data from Hacker News

CSS for printing to paper

voussoir.net

1–10 of 139 posts

Re: CSS for printing to paper

#3
I recently had to figure out a good chunk of this (on my own, I wish I had this resource then) for a one-off project. The biggest thing I learned was to give up all hope of cross-browser printing: just use Chrome. Every browser treats almost every property differently or flat out ignores them, but I found that Chrome had the highest score in doing what I wanted.

Re: CSS for printing to paper

#4
I almost never do real printing (to paper), but this looks really easy to get something working. Also the cheatsheet at the end of the article is a super useful summary of the css rules used. Great article to save in case I face having to build something that prints in the future.

Re: CSS for printing to paper

#7
Browser support for printing CSS is spotty. Worse: some features, like footnotes on every page, don't have any equivalent in CSS I know of.

Is there any easy to use/hack HTML layouting engine where I could experiment with custom CSS attributes and bridge that gap? Would anything from Servo be suitable?

Modifying an entire browser with its bloat is too much effort. There is no JS or cookies on paper (they can be in paper if you wrap them).

Re: CSS for printing to paper

#8
I just laid out a book using Pagedjs.org. Although there were a few bugs in the preview experience, the final output was perfect, and probably took me a quarter the time it would have in InDesign (which I’m fairly competent in).

The real power is in being able to hook up all the templating, CMS APIs, and whatever else you want into your content pipeline. It’s Just HyperText™.

I’d go so far to say that if you’re equally comfortable in HTML/CSS and InDesign, Pagedjs is a superior choice for long form layout.

Re: CSS for printing to paper

#9

I recently had to figure out a good chunk of this (on my own, I wish I had this resource then) for a one-off project. The biggest thing I learned was to give up all hope of cross-browser printing: just use Chrome. Every browser treats almost every property differently or flat out ignores them, but I found that Chrome had the highest score in doing what I wanted.

There are two sites that share a common history that provide a tool for TTRPG players to create homebrew documents, GM Binder and Homebrewery, that both only target Chrome for this reason. It’s great if we can support all browsers and don’t want the site to break in any browser, but we advise users that Chrome is the target almost just so we know authors and readers are on the same page.
Post reply on HN