在哪里可以找到ChromeDriver / Selenium的“打印首选项”的规格?

问题描述

我已经能够在ChromeOptions中找到一些用于打印的偏好设置,例如(在Kotlin btw中)

    val options = ChromeOptions()
            options.addArguments(
                    "--window-size=1920,1200","--kiosk-printing"
            )
    val settings = "{\"recentDestinations\": [{\"id\": \"Save as PDF\",\"origin\": \"local\",\"account\": \"\"}],\"selectedDestinationId\": \"Save as PDF\",\"version\": 2,\"isheaderfooterEnabled\": false}"
    
    val prefs = hashMapOf(
                    "savefile.default_directory" to path,"printing.print_preview_sticky_settings.appState" to settings
    )
    options.setExperimentalOption("prefs",prefs)

但是例如在“ appState”下是否有完整的选项列表?还是可以在“ recentDestinations”甚至“印刷”中引用?

我能找到的最好的是 https://chromium.googlesource.com/chromium/src/+/master/chrome/common/pref_names.cchttps://chromium.googlesource.com/chromium/src/+/master/chrome/common/chrome_switches.cc 但是他们没有告诉我可接受的参数是什么。

解决方法

我想我隐约发现了它:

您可以使用SerializedSettings设置横向,比例和其他打印机属性: https://github.com/chromium/chromium/blob/eadef3f685cd9e96e94fcb9645b6838b6d0907a8/chrome/browser/resources/print_preview/data/model.js

对于特定的打印机规格,您可以设置“ RecentDestinations”: https://github.com/chromium/chromium/blob/eadef3f685cd9e96e94fcb9645b6838b6d0907a8/chrome/browser/resources/print_preview/data/destination.js