Live data from Hacker News

Show HN: ThePDFApi, a Chrome Based PDF Generation API Hosted on AWS

news.ycombinator.com

21–30 of 37 posts

Re: Show HN: ThePDFApi, a Chrome Based PDF Generation API Hosted on AWS

#21
Have you considered offering this as a browser extension? It would greatly increase your market size, and I have worked with (non-technical) people who would love to be able to activate an extension, enter an email address, and email out a PDF (of an invoice) to a colleague.

This workflow is a common one, and really frustrating: "Print -> Save as PDF -> choose location on disk/google drive/dropbox-> Save -> switch to email -> compose email -> enter email address -> enter subject -> add attachment -> navigate to saved location (if I can remember it) -> Send".

You could even add a premium feature that would hit a URL on a schedule, to automate report sending to managers (e.g. of Yahoo Ads or any other platform with similarly terrible reporting).

My manager and I at my old place of work used to spend 1-3 hours/month, times however many people had access to his credit card for their subscriptions.

Re: Show HN: ThePDFApi, a Chrome Based PDF Generation API Hosted on AWS

#22
post #12
post #6

I don't know much about the complexities of this task so excuse my question if it's too obvious. How is it different/better than using puppeteer? If it's better, maybe SxS comparisons of generated pdfs could be a good selling point.

Thanks for leaving a comment, really appreciate it. The idea of creating a comparison between PDFs rendered with different solutions is genius. Definitely gonna add this. Puppeteer would indeed come close in rendering quality. Improvements of using my solution over puppeteer are: 1) I tweaked Chrome headless to have the fonts available to ensure that typography renders as it should. Even emojis work! 2) you don't nee…

You might also want to take a look at https://github.com/GoogleChrome/puppeteer/issues/557#issueco...

Re: Show HN: ThePDFApi, a Chrome Based PDF Generation API Hosted on AWS

#23

Have you considered offering this as a browser extension? It would greatly increase your market size, and I have worked with (non-technical) people who would love to be able to activate an extension, enter an email address, and email out a PDF (of an invoice) to a colleague. This workflow is a common one, and really frustrating: "Print -> Save as PDF -> choose location on disk/google drive/dropbox-> Save -> switch to…

Interesting idea, I've been planning to build a save as PDF extension around it as a case study.

Combining the PDF functionality together with an email function sure is interesting, gonna think this over a bit more. Thanks!

Re: Show HN: ThePDFApi, a Chrome Based PDF Generation API Hosted on AWS

#26
post #4

A little addendum, I'm also contemplating to create a manual service where you could send me a document in any format (JPG, PSD, Microsoft Word) and I'd create a REST endpoint that you can call with the data that you want to have inserted into the document. The output of this rest endpoint would be the binary PDF data. This way your dev team would not have to invest any time at all in the creation of PDF documents. S…

How would you insert data at arbitrary places in the document? Or is this more like a form-filling API or something else?

Re: Show HN: ThePDFApi, a Chrome Based PDF Generation API Hosted on AWS

#27
post #25

This is probably a general headless-Chrome question, but - with something like this, how would you go about specifying margins, page breaks, etc?

For the margins there is a global setting in the API that will set the specified margins on the entire document. You can specify additional margins on top of this by setting a margin in css.

Page breaks are controlled by the CSS properties page-break-after, page-break-before and page-break-inside.

Re: Show HN: ThePDFApi, a Chrome Based PDF Generation API Hosted on AWS

#29
A warning from my own experience: do not use web technologies for any printing (including rendering to pdf) where positioning is critical (e.g. for filling out pre-printed forms). Fiddling with `@media print {…}` and `position: absolute` will work… until there's some minor change in the rendering engine that will throw all that careful work into disarray and leave you asking questions like, "why is this right-aligned bit of text in an 8.5-inch wide container being printed down the middle of my page?" (the preview looked great btw). Oh, and the vertical scale was only slightly short, so I couldn't just scale the page. The right answer in this case was a package that actually spoke pdf and would flow text into a fixed-size box at a fixed location. Oh, and once you've got the file, don't let the browser print it either -- somehow both Firefox and Chrome wouldn't render it to the printer correctly, and of course they would mess up in different ways.

Browsers are good at laying things out on the screen. On paper, not so much.

Re: Show HN: ThePDFApi, a Chrome Based PDF Generation API Hosted on AWS

#30

A warning from my own experience: do not use web technologies for any printing (including rendering to pdf) where positioning is critical (e.g. for filling out pre-printed forms). Fiddling with `@media print {…}` and `position: absolute` will work… until there's some minor change in the rendering engine that will throw all that careful work into disarray and leave you asking questions like, "why is this right-aligned…

What makes this so hard? Why can’t browsers just treat the page size as a viewport? Is the problem dealing with page breaks?
Post reply on HN