Live data from Hacker News

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

github.com

51–60 of 82 posts

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

#51
What's up with the built in queue? I feel like that belongs in a different script. For one, the built in nodeJS queue is useless in a multiple server environment. You'd still need a distributed queue since this built in one is only local to one server/thread. So the built in queue becomes redundant/pointless for any kind of solution that needs to scale

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

#53

What's up with the built in queue? I feel like that belongs in a different script. For one, the built in nodeJS queue is useless in a multiple server environment. You'd still need a distributed queue since this built in one is only local to one server/thread. So the built in queue becomes redundant/pointless for any kind of solution that needs to scale

Not the OP, but maybe he wanted to keep the install as simple as possible without requiring something like redis. I also haven't looked at the code, but a queue per process is still useful as long as the results can be accessed from any process. Not sure if this is the case. If not, you would seem to be right, in that subsequent requests after "queuing" the job could go to another process/server not aware of the queued job.

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

#55
post #33

Are there any similar wrappers around headless Firefox, which has been released recently (Firefox 55)? Mozilla's documentation ( https://developer.mozilla.org/en-US/Firefox/Headless_mode ) is still incomplete.

I assume they're waiting for Servo

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

#56
post #6

Pretty cool! Check out Google's headless browser API Puppeteer too, they provide a few really useful functions for doing stuff like this. https://github.com/GoogleChrome/puppeteer/blob/master/exampl... Really easy to work around, I used it to build a simple CLI to generate device screenshots of a webpage by modifying the user-agent and resolution to match each device. https://github.com/umpox/generateDeviceScreenshot…

Cool project

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

#57
post #4

Earlier quoted context omitted.

I agree with you but as a 'old' developer, I find it pretty sad that you have to fire up a headless browser + its gigaton of code, to convert a SVG to PNG. But I agree with you, headless chrome can be very useful.

I take your point in general, but I'm not sure this specific task - converting of SVGs - has ever been one that has easily been solved by some tiny amount of code: probably the way I would have done this in the past (say, ten years ago) would have been using Apache Batik's rasteriser, which is far from a lightweight solution itself.

It's not tiny, but in case anybody else is trying to do the same thing, I'd reach for librsvg (https://wiki.gnome.org/Projects/LibRsvg).

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

#59

All I need now is CMYK support in Chrome and I can make HTML based print ready PDF rendering. That would be quite upgrade compared to my current options.

I work on Chrome's PDF generation.

Please file a bug report if you think this is an important feature.

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

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

Actually, all printing in Chrome goes through the PDF generator as an intermediate step.
Post reply on HN