According to the docs, Chrome can be started in headless mode with --print-to-pdf
in order to export a PDF of a web page. This works well for pages accessible with a GET
request.
Trying to find a print-to-pdf solution that would allow me to export a PDF after executing multiple navigation request from within Chrome. Example: open google.com
, input a search query, click the first result link, export to PDF.
Looking at the [very limited amount of available] docs and samples, I failed to find a way to instruct Chrome to export a PDF, after a page loads. I'm using the Java chrome-driver
.
One possible solution not involving Chrome, is by using a tool like wkhtmltopdf. Going on this path would force me to - before sending the HTML to the tool - do the following:
- save the HTML in a local file
- traverse the DOM, and download all file links (images, js, css, etc)
Don't prefer this path as it would require a lot of tinkering [I assume] on my part to get downloads' file paths correct for wkhtmltopdf
to read correctly.
Is there a way to instruct Chrome to print to PDF, but only after a page loads?