Live data from Hacker News

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

news.ycombinator.com

101–110 of 170 posts

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

#101
Print to PDF in the browser?

My main use for that is printing appointment information, tickets, and product listings. The product listings are useful when trying to find in a store something that's supposedly available and in stock. Usually, only the first page is useful. There will be additional useless pages of irrelevant items, deals, and ads.

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

#103
post #7

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/

https://stirlingpdf.io also uses weasyprint !!

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

#104
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.

But in this case the flexibility of HTML is a negative because any layout shift would mess up the positions of the annotations, so fixing the layout (and making sure it’s non-interactive) is helpful here

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

#105
post #7

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/

+1 - Weasyprint is an excellent tool to make pdf from html content, and we're using it at work (with django) to export various documents.

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

#106
I 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.

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

#108
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

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

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

#109
post #60

Earlier quoted context omitted.

I know, even though that depends on the editor. Okular for example places them in an extra file, last I checked. That's not unique to PDFs. HTML files are modifiable. There is nothing preventing an editor to put annotations in it as well.

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…

The W3C standardized HTML annotations years ago. There's a difference between a standard not existing versus people pretending it doesn't exist because it's not implemented by Chrome.

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

#110

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

Post reply on HN