Live data from Hacker News

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

github.com

21–30 of 82 posts

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

#22

I am guessing this works by splitting screenshots of a web page and gluing them as pages in the PDF file. Doesn't that mean the size of the PDF would grow to be large once it passes few pages? How does it handle content (like, tables) that don't have line breaks?

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

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

#23

Can it generate a table of contents with page numbers?

calibre has been able to convert arbitrary HTML files to PDF with Table of Contents with page numbers, links, embedded fonts, arbitrary headers/footers for years, all rendered using WebKit, without a running X server, for years.

ebook-convert file.html file.pdf --pdf-add-toc

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

#25
post #22

I am guessing this works by splitting screenshots of a web page and gluing them as pages in the PDF file. Doesn't that mean the size of the PDF would grow to be large once it passes few pages? How does it handle content (like, tables) that don't have line breaks?

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?

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

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

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

#28

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.

The holy grail of PDF generators, sensible page breaks. Never been done and makes peace in the middle east seem like an easy task.

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

#29

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.

WeasyPrint seems awesome. Going to prototype with it later! Thanks

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

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

Post reply on HN