This is exactly what I do bundled into a nice function added to my .zshrc
chromepdf() {
chrome --headless --disable-gpu --print-to-pdf="$1" $2
} chromepdf() {
chrome --headless --disable-gpu --print-to-pdf="$1" $2
}Alternatively, you can run Chrome headless with the remote debugging API (--remote-debugging-port=9222) and send a Page.printToPDF (https://chromedevtools.github.io/devtools-protocol/tot/Page/...) after some delay.
Edit, I see now that I replied to the wrong comment. It was meant to they who made an alias to it.