url-to-pdf-api icon indicating copy to clipboard operation
url-to-pdf-api copied to clipboard

how to generate a PDF with automatic height?

Open ddahan opened this issue 6 years ago • 3 comments

I use this Puppeteer microservice to generate receipts in PDF. For each receipt, width is always the same, but height changes, according to the article count in the order.

For now, I'm using the article count to approximate the required height for my receipt. It kind of works, but it's not perfect and is a dirty way to do. Is there way to tell Puppeteer API : "Please automatically find the right PDF height, according to the HTML body height, in order to generate a perfectly sized PDF" ?

ddahan avatar Oct 12 '18 18:10 ddahan

This is a great question, but unfortunately I don't know how to achieve it with Chrome rendering. You could look into issues in https://github.com/GoogleChrome/puppeteer if there are similar questions.

kimmobrunfeldt avatar May 14 '19 11:05 kimmobrunfeldt

I use this Puppeteer microservice to generate receipts in PDF. For each receipt, width is always the same, but height changes, according to the article count in the order.

For now, I'm using the article count to approximate the required height for my receipt. It kind of works, but it's not perfect and is a dirty way to do. Is there way to tell Puppeteer API : "Please automatically find the right PDF height, according to the HTML body height, in order to generate a perfectly sized PDF" ?

@ddahan can you please share how exactly you are solving this issue. Iam facing similar issue.

neerajtomar98 avatar Mar 03 '20 07:03 neerajtomar98

I tried to solve this in this branch https://github.com/alvarcarto/url-to-pdf-api/pull/119 but without success.

kimmobrunfeldt avatar May 11 '20 18:05 kimmobrunfeldt