title: ChromeDriver --print-to-pdf after page load
body: <p>According to <a href="https://developers.google.com/web/updates/2017/04/headless-chrome" rel="noreferrer">the docs</a>, Chrome can be started in headless mode with <code>--print-to-pdf</code> in order to export a PDF of a web page. This works well for pages accessible with a <code>GET</code> request.</p>
  
  <p>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 <code>google.com</code>, input a search query, click the first result link, export to PDF.</p>
  
  <p>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 <code>chrome-driver</code>.</p>
  
  <p>One possible solution not involving Chrome, is by using a tool like <a href="http://wkhtmltopdf.org" rel="noreferrer">wkhtmltopdf</a>. Going on this path would force me to - before sending the HTML to the tool - do the following:</p>
  
  <ul>
  <li>save the HTML in a local file</li>
  <li>traverse the DOM, and download all file links (images, js, css, etc)</li>
  </ul>
  
  <p>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 <code>wkhtmltopdf</code> to read correctly. </p>
  
  <p>Is there a way to instruct Chrome to print to PDF, but only after a page loads?</p>