3 ms·
It feels like HTML and CSS could be useful for print layout, but I’ve rarely seen a high quality PDF renderer. I know Atom’s markdown preview uses headless chr
by gorgoiler 6y ago
It feels like HTML and CSS could be useful for print layout, but I’ve rarely seen a high quality PDF renderer.
I know Atom’s markdown preview uses headless chrome under the hood. These are hugely heavyweight tools but the output is very high quality.
Are there any other recommended tools for going an HTML route, for typesetting? I’d much rather design pages that way than use InDesign, PDF scripting, or TeX.
- blauditore 6y ago> but I’ve rarely seen a high quality PDF renderer What exactly do you mean by this? That HTML-to-PDF converters mess up the layout, or similar? You might be aware of this, but it's still worth pointing out that you can specify a different stylesheet for the print version of an HTML page than the default one. I've used this in the past for websites where the customer wanted to use a product description page directly for generating PDFs, without having to do the work twice. We also used some Java-based HTML-to-PDF renderer, which was not perfect but had full support of CSS 2.1 and some support of CSS 3 (and this was several years ago). I think the library was Flying Saucer (based on itext).
- mkayokay 6y agoI have been using Python with Jinja2 templates and Weasyprint[1] for PDF creation for a side project of mine. The libary does have its css limitations but the PDFs it produces look good enough for me. [1] https://weasyprint.org/ https://weasyprint.org/
- elondaits 6y agoYes, I was going to recommend WeasyPrint as well.
- PetahNZ 6y agoAlthough not exactly what you want, my day job is basically implementing systems that take SVG's produced in design tools, pipe them through to a customer UI for designing print books, posters etc, then renders high res images server side with Chrome headless and finally sending them off to the printer. SVG does a great job, but still requires a lot of coding for laying out the text, line breaks, pages, etc.
- erichurkman 6y agoA true CSS+HTML-powered print renderer is PrinceXML. https://www.princexml.com/samples/ https://www.princexml.com/samples/ Having used it for over a decade, it's a wonderful tool.
- Someone1234 6y agoThat product's license tiers are a complete non-starter, unprofessional, and they "call for pricing" on the only potentially usable license (but don't provide a copy of the CSO License for review before calling). > A Prince Server License can be installed on a single server to produce PDF documents for company-internal use, or documents that are made available to everyone free of charge. They never define what "company-internal use" means, even in the actual terms[0]. This was clearly written by a non-lawyer, and any company worth its salt wouldn't touch this (the "FAQ" isn't a legally binding document, and even that is incredibly vague/unhelpful). > You many not use Prince to generate documents that are part of a Commerial Service, for example invoices and monthly statements. So "company-internal use" doesn't include order/remittance/invoice/receipt to your company's suppliers/vendors? That's just bizarre, the whole licensing is. The "Service License" feels like a Honey Trap. [0] https://www.princexml.com/license/ https://www.princexml.com/license/
- vraylle 6y agoWe use WKHTMLTOPDF (https://wkhtmltopdf.org/ https://wkhtmltopdf.org/). In our case it's in the Rotativa package (.NET MVC). There are a few caveats; it uses an older headless WebKit engine that doesn't support everything. We use the QT Web Browser (http://www.qtweb.net http://www.qtweb.net) to test/debug when needed. We do design pages to be specific "paper" sizes and lean on SVG a lot for anything fancy. We have some JS that breaks long tables into multiple tables, etc. But the resulting output looks flawless.
- leephillips 6y agoModern CSS technologies such as grid are convenient for laying out webpages. But there can be no “high quality PDF renderer” from HTML/CSS. The result will always look as crude as a web page. In order to produce a high quality document, you need a sophisticated line breaking algorithm such as that deployed by TeX or some other software.
- gorgoiler 6y agoIt is possible to use CSS to have justified text with hyphenated line breaks. Font technology like Opentype will manage ligatures etc. I feel like the basics of laying out glyphs are all there. What doesn’t feel so great is page filling, and knowing how to break sections so that one doesn’t have a new section at the bottom of a page with only a few lines of text.
- werdnapk 6y agoI use wkhtmltopdf without much issue. Sure, it has some limitations and is built around an older html rendering engine, but it works well for a free tool. I use it mainly via the wicked_pdf ruby gem and I'm sure there are wrappers available for other languages too.