Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98372

Using Selenium and ChromeDriver, automatically scale the size of the page on print

$
0
0

I'm writing a script to automatically print a set of web pages in Chrome. If I were to print them manually, I'd choose "Custom" from the Scale drop down and enter 50 into the input field below.

enter image description here

I can't figure out what arguments to pass in to replicate this setting when I automatically print these pages in bulk using Selnium with ChromeDriver.

appState = { "recentDestinations": [{
                "id": "Save as PDF",
                "origin": "local",
                "account": "",
                "printing.scaling": 'Custom', # <== Does it go here?
             }],
             "selectedDestinationId": "Save as PDF",
             "version": 2,
             "printing.scaling": 'Custom',  # <== Or here?
           }
profile = { 'printing.print_preview_sticky_settings.appState': json.dumps(appState),
            'printing.print_header_footer': False,

            # So many different versions of things I have tried :-(
            'printing.scaling': 'Custom',
            'printing.scaling_type': 'Custom',
            'print_preview.scaling': 'Custom',
            'print_preview.scaling_type': 'Custom',
            'printing.custom_scaling': True,
            'printing.fit_to_page_scaling': 50,
            'printing.page_scaling': True,
          }
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option('prefs', profile)
br = webdriver.Chrome(options=chrome_options)

All of the different options shown above were guesses after reading through a lot of the Chromium source trying to get a hint.

https://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc?view=markuphttps://chromium.googlesource.com/chromium/src/+/master/printing/print_job_constants.cchttps://chromium.googlesource.com/chromium/src/+/master/printing/print_job_constants.h

I'm out of leads... anyone have any ideas? Thank you!


Viewing all articles
Browse latest Browse all 98372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>