Live data from Hacker News

CSS for printing to paper

voussoir.net

41–50 of 139 posts

Re: CSS for printing to paper

#41

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 equal…

I wonder how the finer issues of typesetting are handled with print CSS compared to dedicated typesetting software nowadays.

CSS is very compelling, but then based on my personal experience as print media designer the likes of InDesign are full of various special tricks (and language-specific, too) for alleviating white space corridors, handling hanging punctuation, hyphenation, etc. that the enterprise-level software tends to accumulate (due to the business model if nothing else).

Re: CSS for printing to paper

#42

Earlier quoted context omitted.

@media print { @page { @bottom-center { content: counter(page) } } works with https://pagedjs.org

And it's not just a Paged.js thing. No "hacks" necessary. https://www.w3.org/TR/css-page-3/#page-based-counters

What browser does it work in natively? I tried this a couple of years ago and a few people claimed that it worked in kiosk mode for Chrome but I couldn't get it to work in any browser.

Re: CSS for printing to paper

#44

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 equal…

I've been test-driving the web pdf build tool for Asciidoc, asciidoctor-web-pdf[1], for a few years, which uses Paged.js as the template engine before CSS PMM has its go. I like it - I like it a LOT[2] - but Puppeteer-Chrome bugs breaks the build on the regular, or requires a rework of templates. So the web-pdf team started just releasing docker images that include a tested Chromium version (among other things), so as to keep that from being such a PITA. Which is fine. Howaaaayyyyyyyver . . that shines a spotlight on a problem with this workflow[3]: the dependency on browser rendering kit.

[1] https://github.com/ggrossetie/asciidoctor-web-pdf

[2] Asciidoc has four major PDF pipelines in some form of maintenance. The vanilla, asciidoctor-pdf, is a Ruby-based Prawn PDF generator, and it's good but limited in terms of layout - you end up having to extend the core Asciidoctor processor for a lot of tricks like LoT/LoF. Asciidoctor-pdf, and I really want to emphasize this, is the official PDF pipeline for adoc files. The older pipeline, FOPUB, is based on DocBook, which Asciidoc has equivalency with. But DocBook means XSL, and XSL means cheating on Russian roulette because just one out of six chance of ENDING THE PAIN is not enough. The odd man out is DBLATEX, which goes Asciidoc->DocBook->LaTeX-> PDF, and . . whew, ok man, you're jumping three markup languages, dude. Other than that, LaTeX is pretty much the gold standard for layout markup. Finally, we got this thing, asciidoctor-web-pdf, which honestly is more or less dead in terms of activity, which sucks. Web-pdf gives me the flexibility of DocBook-XSL (and then some!) but with CSS and, if I need it, JS. Unfortunately, LoT/LoF still needs Asciidoctor extensions . . but you get a lot of toys that aren't possible with asciidoctor-pdf/prawn.

[3] Shared by vivliostyle and a few others.

Re: CSS for printing to paper

#45

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 pa…

You don't have to use a browser . I had very good results with Weasyprint [0]. And there's also PrinceXML [1] if you're willing to pay. [0]: https://weasyprint.org/ [1]: https://www.princexml.com/

Weasy is tight. Unfortunately, my org banned Python across the board, else that would have been my choice.

Re: CSS for printing to paper

#46
post #25

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 pa…

Another issue is ideally, before printing, you'd (I'd) like a chance to re-render canvas based illustrations at resolutions and/or colors that are appropriate for printing. But AFAICT, there's no event "onprint" or something to give a chance to to do that. You can offer a print button in HTML but if the user chooses print directly from the browser you have no chance to respond.

There is onbeforeprint.

Re: CSS for printing to paper

#47

Browser support for printing is so bad that I'm going to have to create a native app for https://www.thingybase.com to have a streamlined workflow of printing labels to a thermal label printer. It works now, but first you have to download a PDF and print that. Google Docs does this too when you hit "Print". I've tried hacks like load the PDF in an iframe and use some JavaScript to print that, but then I get footers w…

This is a really cool project. What’s the pricing?!

Re: CSS for printing to paper

#48

Earlier quoted context omitted.

You don't have to use a browser . I had very good results with Weasyprint [0]. And there's also PrinceXML [1] if you're willing to pay. [0]: https://weasyprint.org/ [1]: https://www.princexml.com/

Weasy is tight . Unfortunately, my org banned Python across the board, else that would have been my choice.

I feel like there's a story here.

Re: CSS for printing to paper

#49

Earlier quoted context omitted.

I’ve worked with thermal printers and they are actually quite capable. They have drawing primitives that allow you to lay out basic graphics and the one I was working with even had basic font support. A native driver is definitely the way to go with these.

> A native driver is definitely the way to go with these. Not if you need to support a bunch of different printers. For me PDF is the way to go, but browsers can't print a PDF via a "Print" button within the HTML, so instead I have to build apps that download the PDF and print it directly through operating system APIs.

I have this in my SaaS, as well. I built an Electron app that ushers the jobs from the cloud to the thermal printer. It all works until there is a failed job and the queue backs up. I haven't quite figured out how to monitor the queue remotely yet.

Re: CSS for printing to paper

#50

Browser support for printing is so bad that I'm going to have to create a native app for https://www.thingybase.com to have a streamlined workflow of printing labels to a thermal label printer. It works now, but first you have to download a PDF and print that. Google Docs does this too when you hit "Print". I've tried hacks like load the PDF in an iframe and use some JavaScript to print that, but then I get footers w…

This is a really cool project. What’s the pricing?!

Free up to 100 items, then $59.98/year ($4.99/mo billed annually).
Post reply on HN