2

I would like to save bunch of websites stored locally on my hard drive as pdf, and when I am doing this by choosing menu > print... > save as pdf it works, but when I am trying to do this via Windows 7 command line with:

C:\GoogleChromePortable\App\Chrome-bin\chrome.exe --headless --disable-gpu --print-to-pdf=C:\Users\pytajnik\Downloads\test.pdf file:///C:/sourcefile.htm

the output is just a blank pdf document. I tried to do it without parameters, but it doesn't help - when I remove --headless chrome just starts with opened site and no file is created, when --disable-gpu file is created but blank again. I think it has something to do with loading page, as it uses JavaScript or because I use portable version of browser. With online pages it works normally.

I have already checked this topic: How to Print to Save as PDF from a command line with Chrome or Chromium

Edit: Ok, I figured it out, it was because of iframes. Could you tell me then how to write a script changing numbers in url so that it will go through all files in folder and how to get rid of headers with date and title on cmd mode, or how to use prind to pdf from gui for multiple cards opened?

Edit2: Ok, I have done that. Now I have problem to print it out in landscape mode. It seems it's impossible: How can I print a webpage in landscape mode using Headless-Chromium on the command line in Linux?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.