title: Missing elements when using selenium chrome driver to automatically 'Save as PDF'
body: <p>I am trying to automatically save a PDF file created with <code>pdftohtmlEX</code> (<a href="https://github.com/coolwanglu/pdf2htmlEX" rel="noreferrer">https://github.com/coolwanglu/pdf2htmlEX</a>) using the selenium (chrome) webdriver.</p>
  
  <p>It almost works except captions of figures and sometimes even part of the figures are missing.</p>
  
  <p>Manually saved:</p>
  
  <p><a href="https://i.stack.imgur.com/dBKTr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dBKTr.png" alt="Manually saved"></a></p>
  
  <p>Automatically saved using selenium &amp; chrome webdriver:
  <a href="https://i.stack.imgur.com/hInP1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hInP1.png" alt="Saved using selenium &amp; chromedriver"></a></p>
  
  <p><strong>Here is my code</strong> (you need the chromium webdriver (<a href="http://chromedriver.chromium.org/downloads" rel="noreferrer">http://chromedriver.chromium.org/downloads</a>) in the same folder as this script):</p>
  
  <pre><code>import json
  from selenium import webdriver
  
  # print settings: save as pdf, 'letter' formatting
  appState = """{
      "recentDestinations": [
          {
              "id": "Save as PDF",
              "origin": "local"
          }
      ],
      "mediaSize": {
          "height_microns": 279400,
          "name": "NA_LETTER",
          "width_microns": 215900,
          "custom_display_name": "Letter"
      },
      "selectedDestinationId": "Save as PDF",
      "version": 2
  }"""
  
  appState = json.loads(appState)
  profile = {"printing.print_preview_sticky_settings.appState": json.dumps(appState)}
  chrome_options = webdriver.ChromeOptions()
  chrome_options.add_experimental_option('prefs', profile)
  # Enable automatically pressing the print button in print preview
  # https://peter.sh/experiments/chromium-command-line-switches/
  chrome_options.add_argument('--kiosk-printing')
  
  driver = webdriver.Chrome('./chromedriver', options=chrome_options)
  driver.get('http://www.deeplearningbook.org/contents/intro.html')
  driver.execute_script('window.print();')
  driver.quit()
  </code></pre>
  
  <p>Sometimes when I manually print this happens, too. But if I then change any of the printing options, the  preview reloads and the image captions are there again and stay there no matter what options I further enable/disable.</p>
  
  <p><a href="https://i.stack.imgur.com/9LA4I.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9LA4I.png" alt="Chrome printing settings"></a></p>
  
  <h3>What I tried so far:</h3>
  
  <ul>
  <li>different Chrome webdriver versions (71, 72, 73) from this site: <a href="http://chromedriver.chromium.org/downloads" rel="noreferrer">http://chromedriver.chromium.org/downloads</a></li>
  <li>enable background graphics by adding '"isCssBackgroundEnabled": true' to the appState</li>
  </ul>