I'm trying to "Print as PDF" a set of webpage reports repeatedly with a Selenium ChromeDriver script in Python. As you can see below, if we have the "Background graphics" option selected, the header of the report renders perfectly. However, when I run Selenium, I cannot figure out how to set the parameter for background graphics. The saved PDF will instead look like this: Here is a minimally reproducible script that I've been attempting to run: import selenium from selenium import webdriver import json from time import sleep import os chrome_options = webdriver.ChromeOptions() settings = { "recentDestinations": [{ "id": "Save as PDF", "origin": "local", "account": "", }], "selectedDestinationId": "Save as PDF", "version": 2, #"cssBackground": 2, } prefs = {'printing.print_preview_sticky_settings.appState': json.dumps(settings), } chrome_options.add_experimental_option('prefs', prefs) chrome_options.add_argument('--kiosk-printing') CHROMEDRIVER_PATH = '/usr/local/bin/chromedriver' driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=CHROMEDRIVER_PATH) driver.get("https://dash.gallery/dash-multipage-report/") sleep(3) driver.execute_script('window.print();') sleep(5) driver.quit() I've done some digging on Chromium's documentation and I believe that I've found the cssBackground setting here. Additionally, there's a BackgroundGraphicsModeRestriction in this file that might be affecting things? I found what I thought would be a useful lead to setting the value in this StackOverflow post but I can't seem to put the pieces together and check that "Background graphics" box from the start. Any help that you can provide would be incredibly appreciated as I'm pretty stuck here. I've also tried rendering my page's CSS with -webkit-print-color-adjust:exact; but it doesn't seem to capture the entire background. Continue reading...