Live data from Hacker News

Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

news.ycombinator.com

41–50 of 170 posts

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#42
post #11

Don’t. Show a web page and open the print dialog, and tell people to save as PDF. All major browsers support this, and the browser HTML to PDF code is the most robust and accurate.

There's nothing in OP's question that suggests this is a one-off operation in response to a user action. It's very likely to be a massive batch operation of a ton of HTML files that might not even be their own site.

this is the case indeed

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#43
If your HTML is simply an intermediary to get you to a PDF, you could consider just skipping straight to building the PDF directly:

https://pdfbox.apache.org

This would be far more efficient than spinning up an entire browser and printing PDFs to disk.

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#45
post #26

Please 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

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.

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#46
post #33
post #26

Please 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

Being (not so easily) edited is often a feature, not a bug.

Is this really that much of a motivation in 2025? Maybe in 2000 you could publish a PDF with the assurance that only the people who paid for Acrobat would be able to edit it, but today, there are a lot of accessible ways to edit PDFs, I don't think I'd choose PDF if I for whatever reason wanted to limit others from editing.

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#48
post #26

Please 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

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.

You could, though. What you are describing are features of an editor, not a file format. I can imagine a browser addon performing the same tasks.

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#49

Earlier quoted context omitted.

Merge what?

I assume combining 2+ documents. For example, attaching a cover page with document owner/version control/lifecycle information to an existing PDF.

That's the easiest thing in the world with free software.

One way is to install poppler-utils and use pdfunite. There are many other open-source packages you can use as well.

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#50
post #48

Earlier 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.

You could, though. What you are describing are features of an editor, not a file format. I can imagine a browser addon performing the same tasks.

[deleted]
Post reply on HN