Live data from Hacker News

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

github.com

71–80 of 82 posts

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

#71

Really nice work. I've had a great experience working with Headless Chrome to convert webpages to PDF for my side project EmailThis ( https://www.emailthis.me ). It uses Puppeteer by Chrome DevTools team - https://github.com/GoogleChrome/puppeteer .

Cool project! I think I am going to start regularly making use of it. Does it email you a PDF attachment, or does it just send an email with the contents of the article within it? When I attempted to use it I did not see a pdf attachment. Regardless/either way, really cool project.

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

#72
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?

(To clarify, Docraptor is just a user-friendly way to use PrinceXML without licensing the latter and setting up all the infrastructure.)

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

#73
post #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.

PrinceXML does a solid job of it, and has for years.

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

#74
post #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.

wkhtmltopdf is a solid tool but its mostly abandoned now. rendering in chrome headless is way faster and more accurate. chrome headless though is lacking a lot of features that wkhtmltopdf provides like headers/footers

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

#75
post #68

Unfortunately, Chrome's kerning when it comes to printing is atrocious. Over the years, I've constantly tested it every once in a while with the hope that it would improve to no avail. Currently, the only print ready HTML to PDF processor that I know is Prince [1] and to a lesser extent Firefox. [1]: https://www.princexml.com/

does Firefox support css paged media?

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

#76

This is interesting :-) I am currently using athenapdf[1] but I will have a play with pdf-bot. [1] https://github.com/arachnys/athenapdf

Core developer of `athenapdf` here :) I had a quick look at `pdf-bot`, and though we both rely on the same underlying technology (we are only just moving to headless Chromium; we were on Electron before) , I believe we have slightly different ambitions with our respective project. But, I may be biased. For example, `pdf-bot` seems to be tied exclusively to a specific converter, and storage backend. With `athenapdf` h…

hi and thanks for athenapdf

I was wondering, does it support custom page headers (or generally running elements)

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

#77
post #26

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

as far as I know wkhtmltopdf still exceeds in some aspects, better page control, margins, headers, footers and tables of contents. chrome still doesn't support them and also no browser supports CSS Paged Media which allows for setting up running elements like page numbering etc

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

#78

Really nice work. I've had a great experience working with Headless Chrome to convert webpages to PDF for my side project EmailThis ( https://www.emailthis.me ). It uses Puppeteer by Chrome DevTools team - https://github.com/GoogleChrome/puppeteer .

Cool project! I think I am going to start regularly making use of it. Does it email you a PDF attachment, or does it just send an email with the contents of the article within it? When I attempted to use it I did not see a pdf attachment. Regardless/either way, really cool project.

Thanks, if it is unable to extract useful content from a page, EmailThis will save it as PDF as send it as an attachmentment.

If you try saving a any discussion website (HN, Stackoverflow, Reddit), you will get the PDF.

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

#79

Earlier quoted context omitted.

Core developer of `athenapdf` here :) I had a quick look at `pdf-bot`, and though we both rely on the same underlying technology (we are only just moving to headless Chromium; we were on Electron before) , I believe we have slightly different ambitions with our respective project. But, I may be biased. For example, `pdf-bot` seems to be tied exclusively to a specific converter, and storage backend. With `athenapdf` h…

hi and thanks for athenapdf I was wondering, does it support custom page headers (or generally running elements)

We have an issue already filed for that, and unfortunately no. That's something CSS Paged Media is supposed to solve.

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

#80

Earlier quoted context omitted.

DonnyV don't you know we need 15 million of the same things in technology :)

Wkhtmltopdf has basically not been updated in years aside from minor bug fixes. It has major issues the author has no plans to fix. I've spend 100s of hours applying workarounds to legacy codebases. All that code could be refactored now. Phantomjs and wkhtmltopdf don't even support doing $(.htmlE).width() from JavaScript. This can complicate laying out the page needless to say. https://github.com/wkhtmltopdf/wkhtmlto…

Why are you doing layout code in javascript? If it can't be done using CSS then your doing something wrong. This is being used to generate PDFs of exact width and height size documents. Hard code the width and height of your page.
Post reply on HN