Edit: It's possible. It's on the introduction page of Chrome Headless
https://developers.google.com/web/updates/2017/04/headless-c...
Look at 'Create a PDF'
PhantomJS made the process pretty easy, but that's probably not a good option these days as it's on the way out.
NightmareJS is pretty much the same and can do it (though I haven't tested myself) [0]
If you want to get a little deeper you can use CEF (Chromium Embedded Framework [1 ]. It basically turns Chrome into a library and there are a bunch of projects that build on top of it (eg Electron, which is what NightmareJS uses underneath).
Here's a project that just uses CEF for converting to PDF [2].
[0] https://github.com/segmentio/nightmare#pdfpath-options [1] https://bitbucket.org/chromiumembedded/cef/overview [2] https://github.com/spajak/cef-pdf
There's also only very rudimentary support for page headers and footers.
wkhtmktopdf is probably ok if you just need a quick single page invoice printout, but the moment you need more (in our case, we definitely do), I can highly recommend paying for https://www.princexml.com/ which has support for a lot of printing specific features.
Here's an example fully rendered in React: https://s3.amazonaws.com/ud-reports/comps-report-86.pdf
And one with svg charts: https://s3.amazonaws.com/ud-reports/chart-report-89.pdf
With -webkit- prefixes you can use even flexbox, and and with js polyfills you'll have all you need.
Of course if I would start a project now, I would use chrome headless, but I don't feel wkhtmltopdf is that bad.
We wanted the same view to be passed into wkhtmltopdf to download it as PDF (with a couple of things omitted).
Unfortunately, the JS didn't execute properly, so you get a borked output.
End result was we render it, capture the HTML after render, and pipe that through to wkhtmltopdf.
Using chrome _should_ resolve that issue and let us just pass the page through.
[1] https://github.com/marcbachmann/node-html-pdf [2] https://en.wikipedia.org/wiki/Xvfb