Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by jancurn on Thursday November 02, 2017 @12:19PM
(#15611774)
You can call the API from anywhere, from resource-constrained servers, Docker containers that cannot run headless Chrome, JavaScript on a website etc. Also, we'll keep adding new features to this act to make it worthwhile to use it, e.g. retries on failures, posting of the file to some URL etc.
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by xilni on Thursday November 02, 2017 @12:58PM
(#15612133)
This is exactly what I do bundled into a nice function added to my .zshrc
chromepdf() {
chrome --headless --disable-gpu --print-to-pdf="$1" $2
}
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by sgolestane on Thursday November 02, 2017 @09:36PM
(#15616058)
Is there anyway to make chrome wait until the page loads?
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by lashkari on Monday November 06, 2017 @02:23PM
(#15638183)
Looks like it prints automatically once Page.loadEventFired is triggered.
Alternatively, you can run Chrome headless with the remote debugging API (--remote-debugging-port=9222) and send a Page.printToPDF (https://chromedevtools.github.io/devtools-protocol/tot/Page/...) after some delay.
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by zulln on Thursday November 02, 2017 @06:44PM
(#15615006)
What do you use this for?
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by nsomaru on Thursday November 02, 2017 @08:01PM
(#15615528)
Save a webpage as a PDF
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by zulln on Saturday November 04, 2017 @06:10AM
(#15624411)
Did not mean to sound negative, but what is the use-case of saving web pages as PDFs? I understand building in the functionality in something else, but here it sounds like you manually type/paste in URLs on a regular basis.
Edit, I see now that I replied to the wrong comment. It was meant to they who made an alias to it.
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by nickjj on Thursday November 02, 2017 @12:20PM
(#15611784)
Also if you can't access this command for whatever reason, another option is to open the print dialog box in Chrome and set the destination to "Save as PDF" and it will work. You'll even get to see a preview. It's very useful for 1 off saves where you want to consume a really long post offline in a PDF viewer.
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by Scarbutt on Thursday November 02, 2017 @05:04PM
(#15614280)
Sure, but the idea is to do it programatically.
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by scaryclam on Thursday November 02, 2017 @12:36PM
(#15611946)
Thanks, I didn't know that was a thing. I was checking out wkhtmltox earlier this week as well.
Looks like there are a lot of options available for this. I suspect Apify's using one of them.
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by jancurn on Thursday November 02, 2017 @01:07PM
(#15612213)
Actually we're simply using Puppeteer - see the source code at the bottom of https://www.apify.com/jancurn/url-to-pdf
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by zulln on Thursday November 02, 2017 @06:45PM
(#15615017)
Any special reason to why you use this over Chrome?
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by nikisweeting on Thursday November 02, 2017 @11:59PM
(#15616589)
Puppeteer is a scripting library for Chrome, built by the Chrome team.
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by Natsu on Friday November 03, 2017 @12:29AM
(#15616701)
There's also wkhtmltopdf that more or less does the same thing using webkit.
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by granda on Thursday November 02, 2017 @12:17PM
(#15611744)
Are there any downsides to me using this to build my own archiver?
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by nikisweeting on Thursday November 02, 2017 @10:15PM
(#15616219)
Many projects are already using this for archiving purposes. Check out https://github.com/pirate/bookmark-archiver
It's robust because the modern web is pretty much built for Chrome, although it can be resource-intensive if you're archiving many sites.
Re:Show HN: Ready-to-use API to convert any web page to PDF ...
by xfer on Friday November 03, 2017 @06:51AM
(#15618123)
converting to pdf is lossy, i wouldn't use this for archiving purposes, normally i use webrecorder for archiving.
chromium --headless --disable-gpu --print-to-pdf=google.pdf http://google.com/
What does Apify add in this case?