I\'m trying to use Google Chrome as a replacement of PhantomJS to render HTML into PDF. So far it\'s been working well for me. The only issue I have that I have not found an
If you really want to do this in a non-hacky way, you have to get down to the chrome devtools protocol since the command line interface doesn't support much (aka --print-to-pdf
is all you get, no print options)
The protocol is documented here: https://chromedevtools.github.io/devtools-protocol/tot
Client libraries are available in many languages, available via package managers.
Here's some examples I put together to demonstrate usage:
The Page.printToPDF
protocol method supports arguments for passing custom markup for header and footer.
Basically, the protocol is defined in a protocol.json
, which client libraries consume to generate the classes/methods for use in any application. These methods encapsulate the lower level communications with the protocol.
All I had to do was install a client library package (via npm or composer), make sure chrome was installed, write a little code, and I'm generating pdfs with no header/footer! Fantastic.