3 ms·
I've been working on a documentation process with Markdown -> HTML + CSS -> PDF for a while and I found that Weasyprint works best. It supports everything I ne
by jim-a-1020401 8y ago
I've been working on a documentation process with Markdown -> HTML + CSS -> PDF for a while and I found that Weasyprint works best. It supports everything I need except CSS target-counter for auto-generation of page numbers in a TOC but otherwise really good.
I really don't like that this uses something non-standard for header/footer and stuff in the margins since that's already covered by standardized CSS @page stuff; https://www.w3.org/TR/css-gcpm-3/ https://www.w3.org/TR/css-gcpm-3/. I'm using that with Weasyprint for automatic header/footers with auto page-numbering, including setting strings from the html to use for heading names, document title, author, etc... example CSS: `h1 { string-set: h1-title content(), h2-title ""; }` + `@page { @bottom-left {content: string(h1-title) string(h2-title);}`.
Weasyprint seems closest to princexml and is free.
- deedubaya 8y agoYou can use CSS page sizing as well, passing it via meta isn't required. https://docs.breezypdf.com/metadata#use-css-for-page-size https://docs.breezypdf.com/metadata#use-css-for-page-size Headers/and footers are just HTML strings and can be super rich with images etc and customized with CSS. Page numbering is free as well in headers/footers. Of course you could just use properly positioned <header> and <footer> tags and do whatever you need to with JS for page numbering.
- jim-a-1020401 8y agoThat's good for page sizing but as other comments on this thread noted, no browsers seem to have proper support for CSS paged media including Chrome. When I tested it, none of the @bottom type stuff or other print/page related CSS worked at all which is why I ended up with Weasyprint since it has it's own engine (and is really great). Example of some more paged media stuff not supported by Chrome; https://www.smashingmagazine.com/2015/01/designing-for-print-with-css/ https://www.smashingmagazine.com/2015/01/designing-for-print.... Another thing Weasyprint does really well which surprised me is automatically carrying over table headers onto subsequent pages when a table is split across pages, which is really nice.
- oliwarner 8y agoSpeaking as somebody who also puts a lot of stuff through WeasyPrint, I love it but it's bloody slow. Tasked with solving the same problems again, I'd probably look at headless Chromium or Firefox. Their JS PDF renderers are fast and if you're doing enough to keep an instance loaded all the time there's no start up time.