Just 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/
WeasyPrint works really well for me. It can support all of the languages and fonts I need. I run it on AWS Lambda and in Docker as a web service. I previously used WKHTMLTOPDF, but it hasn't been supported for years and doesn't support the latest CSS, etc. It does support JS if you need it, but I'd probably look at headless Chromium or another solution for JS if needed. Edit: Previous post with some good discussion:…
Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
91–100 of 170 posts
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#92Just 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?
#93[0]: https://carbone.io/
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#94A reverse of this question; what is the best way to convert pdf to html? We are required by accessibility law to make our PDFs WCAG compliant however it would be easier to convert these to HTML.
I have been using pdf2htmlex with some success. https://github.com/pdf2htmlEX/pdf2htmlEX
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#95openhtmltopdf is what we're using. Some outdated versions.
Been using this as well. It's worth noting that while the original project appears to have been abandoned, it has since been forked and is currently maintained here: https://github.com/openhtmltopdf/openhtmltopdf
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#96Earlier quoted context omitted.
Or, please do? I use PDF's so I can send them to my iPad to read offline, highlight them, annotate them, and then send them back to my filesystem with highlights and annotations intact. I sure can't do that with any "nice formats" like HTML or TXT or EPUB or MOBI.
PDF is literally digital paper. HTML has logical structure, it can adapt to different displays, etc. Sometimes you want one, sometimes, the other.
This is the part that the top commenter missed. Instead they decided that one format is "nice" and the other, by implication, isn't. I find PDFs a lot easier to keep organized en masse, I like that I can use them on any of my devices and it's easy for me to use them when I'm doing in-depth reading such as an ebook. Doubly so because my ereader also does text to speech and syncs across devices so I can read on my tablet while I'm on the exercise bike and then switch to listening to the same book on my phone with minimal seams and without losing my place. It is, in a word, nice.
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#97chrome --headless --disable-gpu --print-to-pdf https://example.com
Can Firefox do this? with an elaborate script that relies on xdotool
So I used Firefox for multi-page documents and Chromium for single-page invoices.
I spent a lot of time with different versions of both browsers, and numerous quirks made a very unpleasant experience.
Eventually I settled on Chromium (Ungoogled), which I use nowadays for invoices.
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#98Earlier quoted context omitted.
PDF is designed for annotations in the file format. You annotate in one editor, you can change the annotations in another. You can always distinguish between original content and annotations. I see no indication that Okular stores highlights or annotations in a separate file, that would be bizarre. There is no mechanism for annotations in HTML or the other formats I listed. An editor would just be editing the origina…
It definitely used to be bizarre then: https://superuser.com/questions/333378/where-does-okular-sto...
Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#99Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?
#100I'd love to go the other way: convert a PDF into a self contained HTML page that renders properly in a browser. It's been way harder than I thought it would. Any advice?
You could embed it as a base64 blob, embed PDF.js (which is included by browsers anyway, I think) and use that to render it in the HTML. But I realize you probably meant a static HTML without JavaScript.