6

When entering the following command in Windows 10 and start a headless chrome version, nothing is happening (with/without extensions):

"c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" 
      --disable-extensions --headless --disable-gpu --print-to-pdf

It just returns to the command line silently and I can't find any pdf file.

Does anybody had the same issue and manage to solve it ?

I'm using : Google Chrome 63.0.3239.84 (Official Build) (64-bit) (cohort: 63_win_84)

ic3
  • 7,489
  • 11
  • 62
  • 109
  • Possible duplicate of [Headless Chrome to print pdf](https://stackoverflow.com/questions/46074235/headless-chrome-to-print-pdf) – Chris Moschini Nov 04 '19 at 17:15

3 Answers3

8

It looks like Chrome doesn't have rights to write in the directory.
Try to launch command with --enable-logging flag. Like:
"c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --enable-logging --disable-extensions --headless --disable-gpu --print-to-pdf
You will receive an error. Fix it and it will start to work. You can find more information here:
How do I use Headless Chrome in Chrome 60 on Windows 10?

Dima Kurilo
  • 2,136
  • 1
  • 22
  • 26
  • 1
    That's working, got [1224/095554.741:ERROR:headless_shell.cc(530)] Writing to file output.pdf was unsuccessful, could not open file: FILE_ERROR_ACCESS_DENIED – ic3 Dec 24 '17 at 09:05
  • 2
    after adding the location it works, great. --print-to-pdf=c:\temp\output.pdf. Thanks – ic3 Dec 24 '17 at 09:11
0

I was experiencing this problem.

My solution was to go and download the Canary Build for Chrome. https://www.google.com/chrome/browser/canary.html

This will then get installed to C:\User\userName\AppData\Local\Google\Chrome SxS\Application. Try running your commands pointing to this install.

0

chrome needs full path also.

To use it in cmd.exe:

start chrome --enable-logging --headless --disable-gpu --print-to-pdf=%cd%\output.pdf https://www.google.com/
rofrol
  • 13,168
  • 7
  • 73
  • 68