Live data from Hacker News

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

github.com

41–50 of 82 posts

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

#41

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.

[deleted]

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

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

CSS isn't really that flexible though, say you want a repeated header or footer on each page, you are going to have a real hard time getting it to work perfectly. And good luck if you then need to internationalize it and support different document sizes (A4 vs legal). It's not impossible, but it's a lot more work than it should be.

One of the best ways I've used to generate PDFs is by using a DOCX as a template, and replacing certain placeholders within the document (a DOCX is a ZIP containing a few XML files). It's great if you work in a corporate environment, as it's easy for non-technical staff to make it look exactly how they want and it's easy to update (just replace a file and check it works). You can use headless LibreOffice to convert DOCX to PDF.

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

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

We had an absolutely ghastly time last year trying to implement wkhtmltopdf in a Rails app - we probably wasted an entire week fighting with both Wicked PDF and PDFKit before we just gave up and wrote something using Prawn instead (which was, of course, extremely time-consuming in a different way, but at least the end result was good).

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

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

That's one hell of a "just".

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

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

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

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

#47
post #39

Earlier quoted context omitted.

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

CSS isn't really that flexible though, say you want a repeated header or footer on each page, you are going to have a real hard time getting it to work perfectly. And good luck if you then need to internationalize it and support different document sizes (A4 vs legal). It's not impossible, but it's a lot more work than it should be. One of the best ways I've used to generate PDFs is by using a DOCX as a template, and…

I was wondering why OP stopped at DOCX without taking it from there to PDF. The suggestion of a template document is a very practical tip; thanks!

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

#48

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 .

Just a heads up -- your site emailthis.me is down.

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

#49

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 .

Just a heads up -- your site emailthis.me is down.

Sorry about the brief downtime. It's back up now.

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

#50
post #37

Earlier quoted context omitted.

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

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/wkhtmltopdf/issues/2419
Post reply on HN