Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
111–120 of 170 posts
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#112Just print to PDF in a browser, or automate that using a browser automation tool. For a non-browser-based open source solution, WeasyPrint. https://weasyprint.org/ For a proprietary solution, try Prince XML: https://www.princexml.com/
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#113https://gotenberg.dev/ ...has been working well for me for the last few years. It's a headless instance of Google Chrome with a golang wrapper. Runs well in Docker or a cloud instance.
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#114I wrote a solution in 2010 that used headless Firefox with some plugins to generate a PDF and then had the graphic designer write print CSSes. It was driven by Perl and was a convenient way for non-programmers to design forms. Unfortunately, that server and software stack is still around and still in production.
> Unfortunately, that server and software stack is still around and still in production. that means you did a good job.
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#115Earlier quoted context omitted.
> Unfortunately, that server and software stack is still around and still in production. that means you did a good job.
2010-era Firefox is probably plagued by security holes.
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#116https://gotenberg.dev
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#117Puppeteer and Playwright are the main open-source options nowadays, both solid for HTML → PDF once your print CSS is sorted. Don’t forget proper page breaks (break-before/after/inside) — e.g. break-after: page works in Chromium, while always doesn’t. For trickier pagination you can look at Paged.js, and I’d test layouts in Chrome/Edge before automating. Shameless plug: I run yakpdf.com, a hosted Puppeteer-based servi…
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#118Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#119jsPDF is a work of art https://parall.ax/products/jspdf
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#120Please don't turn nice formats into a format that's similar to screenshots of text. Pandoc has an option to pack all images and styles needed to render the page into one html file: pandoc --self-contained input.html -o output.html
> Please don't turn nice formats into a format that's similar to screenshots of text Converting HTML to PDF shouldn't result in an image wrapped in a PDF. Text will be preserved as text in the final PDF. (Unless the converter is garbage, of course.)
I didn't mean literally an image, hence saying image-like. You get similar limitations to when using OCR, which seems very image-like to me