Live data from Hacker News

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

github.com

61–70 of 82 posts

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

#62
post #31

Earlier quoted context omitted.

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

What problems did you run into with wkhtmltopdf? We have been using it without much trouble. Chrome pdf generation is nice but wkhtmltopdf generates smaller PDFs with table of contents.

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

#63

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` however, we are moving more, and more towards building a toolkit or rather, framework for other people to construct their own conversion processes (or even microservice)[0].

Consequently, we are working towards general abstractions like fetching, converting, and uploading, that can have different implementations (e.g. wkhtmltopdf, LibreOffice, Weasyprint, etc).

With our microservice assembly as well, we are focused heavily on ensuring we have:

1. Instrumentation, and metrics (which `pdf-bot` appears to currently lack)

2. Support for different retry mechanisms (e.g. retry using the same converter or retry using a different converter)

3. Support for multiple input MIME types

4. Synchronous API calls (`pdf-bot` appears to be mostly asynchronous, with batch processing, and callbacks)

5. Ease of installation (e.g. Docker), and configuration

We also have a CLI assembly[1] that can support custom JavaScript plugins[2] (e.g. Markdown -> PDF, Readability, etc). So you don't need to run a service or make API calls for conversions.

[0] https://github.com/arachnys/athenapdf/tree/v3/pkg

[1] https://github.com/arachnys/athenapdf/blob/v3/cmd/cli/main.g...

[2] https://github.com/arachnys/athenapdf/tree/v3/pkg/runner/plu...

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

#64

Earlier quoted context omitted.

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

What problems did you run into with wkhtmltopdf? We have been using it without much trouble. Chrome pdf generation is nice but wkhtmltopdf generates smaller PDFs with table of contents.

All kinds of problems that others have mentioned above, plus in terms of the Rails integration, it felt like we hit almost every one of the open issues on the GitHub repos for both Wicked PDF and PDFKit. I vaguely recall fonts in production being a problem, a general lack of reliability, performance issues, fiddling around with various different binaries of wkhtmltopdf to find one that maybe worked... probably other things besides. It was a bad week and I wish I hadn't reminded myself!

(With no disrespect, of course, to the authors of these libraries - they just didn't work well for us.)

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

#65

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

I was first wondering about all the complexity in the API as well (why a built-in queue, webhook, retry policy and storage interface when the actual transaction I'm interested in is just "url -> pdf blob"?)

However, I think this is necessary if you want to fit it into a microservice with a REST interface. For REST, I think the usual expectation is that a) the request returns quickly and b) you can submit any number of requests in parallel. Given that loading a page into headless chrome, rendering it and generating a pdf is both resource intensive and time consuming, I guess you need some way to decouple that process from the interface.

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

#66

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…

Thank you for athenapdf and for rescuing me from the pains of wkhtmltopdf - I am a happy user. :)

My only small problem with it was the somewhat complex setup for using athenapdf-service with a new project (especially since I use docker-machine) but I have now mostly automated the whole thing.

Just out of interest - do you consider asynchronous an advantage (being a Node developer I generally love async very much)? Not that it matters to me - my needs are trivial for the service to handle.

Edit: actually I can see how it async would make my life much more complicated for my simple use case - I would have to write something to track requests and responses rather than just looping through a bunch of URL's that need converting.

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

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

I'll upvote both this and track bug report, if linked.

Yes, CMYK support is very tempting feature for the whole print industry.

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

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

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

#69

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…

Thank you for athenapdf and for rescuing me from the pains of wkhtmltopdf - I am a happy user. :) My only small problem with it was the somewhat complex setup for using athenapdf-service with a new project (especially since I use docker-machine) but I have now mostly automated the whole thing. Just out of interest - do you consider asynchronous an advantage (being a Node developer I generally love async very much)? N…

That's interesting feedback! Thank you :)

We actually went with Docker for the set up because it simplified dependency management tremendously, and it allowed us to deploy on platforms like Kubernetes, Swarm, and ECS. As a plus, it gave us some confidence that if it works for us, it should work for others (obviously, we have come across cases where Docker behaves differently across platforms).

I consider asynchronous processing (in this context) as advantageous in some cases. Indeed, when we were refactoring `athenapdf`, we considered introducing a message queue for workers to pull work from, and to put back when the work completes. The problem with this however, is that we can't as easily scale horizontally (i.e. introduce node replicas behind a load balancer), as if we tried to get / update a job, we may not get the same node we originally got. I mean, the solution can be as easy as introducing a centralised message queue of sorts (or even a sticky session), but that complicates the set up process, so we decided against it.

Taken together, for our specific use cases, we believe it is a lot simpler to consume a synchronous API. No webhooks / callbacks. No polling. No concerns over acknowledgement. If a HTTP call fails, we will know about it immediately. If a complex retry mechanism is needed, we think this should be accomplished in the client application.

In the long term, I believe we should have a toolkit that can easily be plugged into a wider orchestration engine like Conductor (https://netflix.github.io/conductor/). That way, anyone can develop their own conversion process pipeline with ease.

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

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

Prince is awesome. Its support for paged media has impressed me again and again.
Post reply on HN