Live data from Hacker News

Show HN: Webpage to PDF Microservice

imti.co

11–20 of 36 posts

Re: Show HN: Webpage to PDF Microservice

#11
post #6

Earlier quoted context omitted.

Why not simply press Ctrl+p and print to PDF?

We have tried it in the past, just doesn't work reliably with different html configurations. Does ctrl+p on this page -> https://jaresume.com/thomas look good for you?

Have you tried using a print media stylesheet? You could hide the navigation, reduce the whitespace, maybe shrink the font size a little bit, and remove link text decoration.

Re: Show HN: Webpage to PDF Microservice

#12
post #11

Earlier quoted context omitted.

We have tried it in the past, just doesn't work reliably with different html configurations. Does ctrl+p on this page -> https://jaresume.com/thomas look good for you?

Have you tried using a print media stylesheet? You could hide the navigation, reduce the whitespace, maybe shrink the font size a little bit, and remove link text decoration.

Great idea. I have used print media sheets in the past, but found them easy to have regressions e.g. elements that are introduced but not hidden. A webpage to pdf process is also vunerable to that though.

I think ideally, because the resume renderer is a react component, I'd rather just boot up chromium with the react component and resume data and do a fully clean render of the page into pdf.

We shall see.

Re: Show HN: Webpage to PDF Microservice

#14
post #13

A basic command line alternative using Headless Chrome[1]: chrome --headless --disable-gpu --print-to-pdf https://www.chromestatus.com/ [1] https://developers.google.com/web/updates/2017/04/headless-c...

Similar functionality is packaged in wkhtmltopdf, which essentially runs Webkit headless to print to PDF.

https://wkhtmltopdf.org/

Re: Show HN: Webpage to PDF Microservice

#15
I'm still looking for a service like this, but that creates a nicely tagged PDF and conveys the HTML structure in the PDF tags.

Tagged PDFs are a requirement in many processes for accessibility or archival reasons.

Re: Show HN: Webpage to PDF Microservice

#16
I find wkhtmltopdf very difficult to work with, for instance the official documentation is just a man [1].

I discovered the project Weasyprint[2] a few months ago. I find it easier to use, and very powerful when using Python. You can define a custom loader to inject images or styles generated on the fly for instance.

There are still some missing features compared to wkhtmltopdf, such as defining a custom footer and header, but it's a very promising project.

[1] https://wkhtmltopdf.org/usage/wkhtmltopdf.txt

[2] https://github.com/Kozea/WeasyPrint/

Re: Show HN: Webpage to PDF Microservice

#17
You can achieve this using just the browser.

In Chrome Dev Tools, click on the devices button (the icon with the phone and tablet). Using the top-right menu, select "Capture full size screenshot".

Walla, you now have a full size screenshot that you can convert into PDF.

Incidentally, I am author of https://www.pagedash.com, which is a personal web scrapbook which allows you to capture the current page as HTML and generate links to share with others.

Re: Show HN: Webpage to PDF Microservice

#18
post #15

I'm still looking for a service like this, but that creates a nicely tagged PDF and conveys the HTML structure in the PDF tags. Tagged PDFs are a requirement in many processes for accessibility or archival reasons.

Why not using HTML instead of PDF? I'm the author of an extension that allows to save faithfully a web page into an HTML file [1]. From my point of view, that should be the best solution for archiving web pages in a file. Votes on HN disagree with me though [2], I wished I could understand why.

[1] https://github.com/gildas-lormeau/SingleFile

[2] https://news.ycombinator.com/item?id=18243721

Re: Show HN: Webpage to PDF Microservice

#19
post #16

I find wkhtmltopdf very difficult to work with, for instance the official documentation is just a man [1]. I discovered the project Weasyprint[2] a few months ago. I find it easier to use, and very powerful when using Python. You can define a custom loader to inject images or styles generated on the fly for instance. There are still some missing features compared to wkhtmltopdf, such as defining a custom footer and h…

Since you mention Python, I have found pdfkit[1] to be a pretty good wrapper for wkhtmltopdf. I have a document generation engine that uses it dozens of times a day. Worst part is that wkhtmltopdf in the Ubuntu repos is still compiled (when last checked) without some patch that allows it to run headlessly. I built from source, which was not too difficult.

[1]https://pypi.org/project/pdfkit/

Re: Show HN: Webpage to PDF Microservice

#20

You can achieve this using just the browser. In Chrome Dev Tools, click on the devices button (the icon with the phone and tablet). Using the top-right menu, select "Capture full size screenshot". Walla, you now have a full size screenshot that you can convert into PDF. Incidentally, I am author of https://www.pagedash.com , which is a personal web scrapbook which allows you to capture the current page as HTML and ge…

I tried it with this page only but it didn't work for me. Got a 110Kb png file but it's empty. It is a valid PNG but it's completely blank. Maybe it's buggy.
Post reply on HN