Is there any way to invoke chromedriver's Page.printToPDF() method from python + selenium?
PhantomJS has a similar render() method that can save straight to pdf, which is only available from the privileged client-side REPL of phantomjs. This SO answer shows how to patch a running selenium driver to invoke it, using a custom phantomjs webdriver command (/session/$sessionId/phantom/execute
) to call this.render()
.
Is there something similar that can be done for chromedriver? Either something like phantomjs's execute
command that allows calling into the devtools methods; or a way to invoke printToPDF
directly via a custom driver command?
(Note: I'm trying to render html that's the result of a POST, so alternate solutions like wkhtmltopdf won't work. I can fall back to using selenium's screenshot -> png, but that's burdensome for storage purposes).