1

i have the below code to convert simple web page to pdf and save it to a folder. My destination downloads folder is being ignored and it writes to defaults Downloads folder. Any help is appreciated.

from selenium import webdriver
import json

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--start-maximized")
settings = {
        "recentDestinations": [{
             "id": "Save as PDF",
             "origin": "local",
             "account": "",
         }],
        "selectedDestinationId": "Save as PDF",
        "version": 2
    }
prefs = {'printing.print_preview_sticky_settings.appState': json.dumps(settings)}
download_dir = "C:\\Users\\Testing\\GitHub\\Python\\downloads\\"
prefs2 = {"profile.default_content_settings.popups": 0,
                 "download.default_directory": download_dir,
                # "default_directory": r"C:\Users\Testing\GitHub\Python\\",
                 "directory_upgrade": True,
                 "printing.print_preview_sticky_settings.appState": json.dumps(settings),
                 "download.extensions_to_open": "applications/pdf"
                 }
chrome_options.add_experimental_option("prefs",prefs2)
chrome_options.add_argument('--kiosk-printing')
Pavan V
  • 11
  • 2
  • Hi, based on the other post you have referred to, it appears this flag is delivered on version 87. I have the version 87 and i do not know how to use this flag. Can you please advise? Sorry, i am not an expert on the python or chromedriver. – Pavan V Jan 23 '21 at 20:15

0 Answers0