title: Headless Chrome Webdriver Issue after printing the web page
body: <p>I have a program that goes to Google, and saves the page as a PDF (saves in the directory as the Python file). That's great, but I don't want the Chrome window to open. With a Google search, I found that I can use <code>options.headless = True</code>. But after I put that in my code, it doesn't print the page. How can I fix this issue? The code is below:</p>
  <pre><code>from selenium import webdriver
  import json
  import os
  
  options = webdriver.ChromeOptions()
  options.headless = False  # Setting this to True won't make the page printing work
  
  options.add_argument(&quot;--kiosk-printing&quot;)
  
  settings = {
      &quot;recentDestinations&quot;: [{
          &quot;id&quot;: &quot;Save as PDF&quot;,
          &quot;origin&quot;: &quot;local&quot;,
          &quot;account&quot;: &quot;&quot;
      }],
      &quot;selectedDestinationId&quot;: &quot;Save as PDF&quot;,
      &quot;version&quot;: 2,
  
  }
  
  prefs = {'printing.print_preview_sticky_settings.appState': json.dumps(settings),
           &quot;savefile.default_directory&quot;: str(os.path.realpath('.')),
           }
  
  options.add_experimental_option('prefs', prefs)
  
  driver = webdriver.Chrome(executable_path=&quot;chromedriver.exe&quot;, options=options)
  
  driver.get(&quot;https://google.com&quot;)
  driver.execute_script(&quot;window.print();&quot;)
  </code></pre>
  <p>Thank you for your help!</p>
  <p>~helloworld</p>