This page shows that you can now use chrome to generate a PDF of a webpage using the following CLI command:
chrome --headless --disable-gpu --print-to-pdf https://www.chromestatus.com/
However, it does not state how to specify the output path.
How do you specify the output path?
Open a webpage in Chrome, press Ctrl+P to open the Print dialog and change the destination printer to “Save as PDF”. Hit the “Print” button and the webpage will download as a PDF document. You can also use Chrome's print-to-PDF function to convert to .
If you still cannot see the "Save as", then you need to disable the PDF Viewer and revert to Adobe Reader. By doing this, type "about plugins"(without the quotes) in the address bar in Chrome and press Enter. From the plug-in list, you should disable Chrome PDF Viewer and Enable Adobe Reader.
Which command starts the google chrome web browser in headless mode? As we have already seen, you just have to add the flag –headless when you launch the browser to be in headless mode. With CLI (Command Line Interface), just write: chrome \<br> – headless \ # Runs Chrome in headless mode.
Headless mode is a functionality that allows the execution of a full version of the latest Chrome browser while controlling it programmatically. It can be used on servers without dedicated graphics or display, meaning that it runs without its “head”, the Graphical User Interface (GUI).
chrome --headless --disable-gpu --print-to-pdf="C:/temp/pdftest.pdf" https://www.google.com/
source:
https://cs.chromium.org/chromium/src/headless/app/headless_shell.cc?type=cs&l=63
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With