News for hackers. Stuff that matters.
Re:URL to PDF Microservice by renke1 on Thursday October 05, 2017 @11:08AM (#15409758)
I was playing around with Puppeteer the other day and was wondering if it was possible to render a web page to a single page PDF (a page with fixed width and variable height). Basically like creating screenshot without losing the text information. This would solve a lot problems such as sticky elements hiding text like in this example [1].

[1]: https://url-to-pdf-api.herokuapp.com/api/render?url=https://...

Re:URL to PDF Microservice by kimmobru on Thursday October 05, 2017 @12:07PM (#15410265)
That's a good idea! You can achieve this by adding e.g. &pdf.width=1000px&pdf.height=10000px parameters.

Sometimes you can get rid of the sticky headers with &emulateScreenMedia=false parameter if the page has well implemented @media print rules in CSS. We decided to use page.emulateMedia('screen') with Puppeteer to make PDFs look more like the actual web page by default.

Pages which use lazy loading for images may look incorrect when rendered. &scrollPage=true parameter may help with this. It scrolls the page to the bottom before rendering the PDF.

Using these options make the PDF better: https://url-to-pdf-api.herokuapp.com/api/render?url=https://...

Re:URL to PDF Microservice by sid- on Thursday October 05, 2017 @01:54PM (#15411085)
I bet that breaks on infinite scroll pages ?