I have read through a few questions/answers that provide test codes to print to pdf using Selenium(chromedriver) that work for standard web pages - see below:
import pandas as pd
import numpy as np
import json
from selenium import webdriver
appState = {
"recentDestinations": [
{
"id": "Save as PDF",
"origin": "local",
"account": ""
}
],
"selectedDestinationId": "Save as PDF",
"version": 2
}
profile = {'printing.print_preview_sticky_settings.appState': json.dumps(appState)}
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option('prefs', profile)
chrome_options.add_argument('--kiosk-printing')
driver = webdriver.Chrome(executable_path='PATH_TO\chromedriver.exe',chrome_options=chrome_options)
driver.get('https://stackoverflow.com/questions/54184647/how-to-send-ctrl-p-to-a-web-browser-in-python/54185741')
driver.execute_script('window.print();')
but does not work for a .htm path: https://www.sec.gov/Archives/edgar/data/857855/000085785520000011/ucbi1231201910-k.htm
i.e.
driver.get('https://www.sec.gov/Archives/edgar/data/857855/000085785520000011/ucbi1231201910-k.htm')
driver.execute_script('window.print();')
I can manually Save as PDF so not sure what to do