Live data from Hacker News

Show HN: Pdf-Bot, an API/CLI for Generating PDFs Using Headless Chrome

github.com

31–40 of 82 posts

Re: Show HN: Pdf-Bot, an API/CLI for Generating PDFs Using Headless Chrome

#31
post #26

How does this compare to wkhtmltopdf, which, IIRC, uses WebKit to render the pdf?

We actually used wkhtmltopdf before we started using pdf-bot. wkhtmltopdf development has slowed a lot, it is very unstable and you need to run a 2 year old alpha version to support flexbox (if I remember correctly) :-) headless chrome is a lot more stable choice imo.

Re: Show HN: Pdf-Bot, an API/CLI for Generating PDFs Using Headless Chrome

#32
post #22

Earlier quoted context omitted.

It uses Chrome's built-in print-to-PDF functionality via Chrome Debug/DevTools Protocol. In other words it creates PDF files with real vector graphics and text, not just images embedded in PDF. Page.printToPDF: https://chromedevtools.github.io/devtools-protocol/tot/Page/...

I didn't know that existed. How good is it with corner cases? HTML->PDF is a notoriously difficult problem; even generating PDF is. There are several software services which charge well for doing that (Docraptor, PrinceXML). If it's smooth and handles everything well, is there any reason someone should pay for them?

It's available from the normal Chrome print menu, so you can test it yourself easily. But to answer: I haven't used it extensively, but CSS and Javascript tend to make it a bit tricky. When you are viewing a webpage in the browser, you have one viewport, and scrolling can change the appearance or position of elements. Translating this to one long PDF is troublesome on some websites. As to what companies do that provide this as a service? I've got no clue, maybe brand this as their unique service? :D

Re: Show HN: Pdf-Bot, an API/CLI for Generating PDFs Using Headless Chrome

#34

Nice work ! Depending on your use case, I feel like you guys might be interested in http://weasyprint.org/ . It is an open source HTML to PDF converter written in Python. It passes the Acid2 test and implements CSS Paged Media.

Always nice to discover another open source HTML rendering engine!

I recently discovered https://github.com/ArthurHub/HTML-Renderer formerly know as https://htmlrenderer.codeplex.com/

PDF generation [...] 100% managed (C#), High performance HTML Rendering library

Re: Show HN: Pdf-Bot, an API/CLI for Generating PDFs Using Headless Chrome

#36
post #30
post #19

Interesting to compare this to some of the "old school" solutions for converting web pages to PDF such as htmldoc[0] or html2ps[1]. [0] https://github.com/michaelrsweet/htmldoc [1] http://user.it.uu.se/~jan/html2ps.html

The old school solutions lack any sort of javascript support (per the docs, htmldoc doesn't even support css), so they wouldn't work for a lot of real world websites. That's not really the same use case. A better comparison would be against the likes of wkhtmltopdf[0], which uses webkit, or the pdf generation features of phantomjs. [0] https://wkhtmltopdf.org/

https://github.com/wkhtmltopdf/wkhtmltopdf/issues

1,047 Open 975 Closed

Yep, that's about how I remember it. It was such a pain to build on Windows (especially to get a single static binary) that people contributing fixes would often attain hero status by attaching a random binary to an issue. Specifically, GIF support was broken on the official Windows build for 4+ years:

https://web.archive.org/web/20140917181225/http://code.googl...

Re: Show HN: Pdf-Bot, an API/CLI for Generating PDFs Using Headless Chrome

#37

How well does it work with multiple-page PDFs? One of our banes is generating mixed text/image downloadable reports with sensible page breaks. To save time, we're actually doing those as docx files, with the bonus/risk that clients can edit the content before saving it as a PDF.

Just use WkhtmlToPdf https://wkhtmltopdf.org and wrap a simple service around it.

Re: Show HN: Pdf-Bot, an API/CLI for Generating PDFs Using Headless Chrome

#38
post #26

How does this compare to wkhtmltopdf, which, IIRC, uses WebKit to render the pdf?

Buggy as hell. Doesn't render things as expected. I'm using headless chrome for pdf generation internally and couldn't be happier. I directly call chrome from the command line it couldn't be simpler. I don't know why people need all these wrappers.

Re: Show HN: Pdf-Bot, an API/CLI for Generating PDFs Using Headless Chrome

#39

How well does it work with multiple-page PDFs? One of our banes is generating mixed text/image downloadable reports with sensible page breaks. To save time, we're actually doing those as docx files, with the bonus/risk that clients can edit the content before saving it as a PDF.

There's CSS that's supposed to help with doing this manually, right? Or does your docx export handle this auto-magically? (If so, I'm interested in more details!)

https://developer.mozilla.org/en-US/docs/Web/CSS/page-break-...

Re: Show HN: Pdf-Bot, an API/CLI for Generating PDFs Using Headless Chrome

#40
post #22

Earlier quoted context omitted.

It uses Chrome's built-in print-to-PDF functionality via Chrome Debug/DevTools Protocol. In other words it creates PDF files with real vector graphics and text, not just images embedded in PDF. Page.printToPDF: https://chromedevtools.github.io/devtools-protocol/tot/Page/...

I didn't know that existed. How good is it with corner cases? HTML->PDF is a notoriously difficult problem; even generating PDF is. There are several software services which charge well for doing that (Docraptor, PrinceXML). If it's smooth and handles everything well, is there any reason someone should pay for them?

PDF generation (especially from a JavaScript-enhanced HTML page) has enough corner cases that it is typically best implemented with commercial support paying someone to polish away the rough edges.

There are many "free as in beer" (closed-source), freemium, and/or free trial options offered as a carrot leading to a commercial product. Most have a watermark and/or page count limitations.

http://selectpdf.com/community-edition/ (5 pages max)

Post reply on HN