我正在尝试使用硒(chrome)网络驱动程序自动保存使用pdftohtmlEX(https://github.com/coolwanglu/pdf2htmlEX)创建的PDF文件。
除了图形的标题外,它几乎可以工作,有时甚至丢失了部分图形。
手动保存:
使用Selenium和Chrome WebDriver自动保存:

这是我的代码(您需要与此脚本位于同一文件夹中的Chrome Web驱动程序(http://chromedriver.chromium.org/downloads)):
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 …Run Code Online (Sandbox Code Playgroud)