93 points · by cjimti · 8y ago · 34 comments
chrome --headless --disable-gpu --print-to-pdf https://www.chromestatus.com/
[1] https://developers.google.com/web/updates/2017/04/headless-c...The wkhtmltopdf utility has been around awhile and works great when you get it working correctly on your platform. However, the newest version as of this writing 0.12.5 has a bug prevening TOC generation on some platforms. Some Linux platforms require the installation of Microsoft font packs, and compiling from source leads you down a rabbit hole of dependency hell.
Did you manage to find a workaround for https://github.com/wkhtmltopdf/packaging/issues/2? If so, would appreciate a PR :-)
You need to be sure you're limiting the kind of URLs that people can submit. For example ensure that nobody makes a PDF of :
* file:////etc/passwd
* http://169.254.169.254/latest/meta-data/local-hostname
I'd say over half of the "PDF-creation" projects posted here have been vulnerable to some/all of those attacks. (I continue to be surprised at how many web-to-pdf services exist. I guess there must be a lot of people paying for them?)
We need a reliable way of turning peoples resumes into PDF's
Going to give this a go today or tomorrow.
Doing it with https://github.com/GoogleChrome/puppeteer also works quite well
Does ctrl+p on this page -> https://jaresume.com/thomas look good for you?
Is the error so critical that it must hide your content? Did it accidentally include your AWS keys or something?
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.
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.
I found this setup to be really stable and easy to maintain, so far it has produced around 70k orders per year and has been running for over 4 years now without any hiccups.
Before that I was using phantomjs but it wasn’t as fast and reliable for some reasons that I can’t quite remember now, since I havent touch that part of the app in a long time.
All I remember is that wkhtmltopdf was easier to tweak and compose with.
Tagged PDFs are a requirement in many processes for accessibility or archival reasons.
curl https://service.prerender.cloud/screenshot/https://google.com/ > out.jpg
curl https://service.prerender.cloud/pdf/https://google.com/ > out.pdf
curl https://service.prerender.cloud/https://google.com/ > out.html
https://www.prerender.cloud/