I'm trying to access a set of links and download them using the simplified print format on Firefox using Selenium. My current code downloads the webpage as a pdf in the original form but I need to get it in the simplified form.
Here is my current code snippet which downloads the pdf in the original format.
from time import sleep
from helium import start_firefox
from selenium.webdriver import FirefoxOptions
options = FirefoxOptions()
options.add_argument("--start-maximized")
options.set_preference("print.always_print_silent", True)
options.set_preference("print.printer_Mozilla_Save_to_PDF.print_to_file", True)
options.set_preference("print_printer", "Mozilla Save to PDF")
options.set_preference("print.use_simplify_page", True) # Does not seem to download in the simplified form
driver = start_firefox("https://www.hsph.harvard.edu/nutritionsource/selenium/", options=options, headless = True)
driver.execute_script("window.print();")
sleep(10) # Found that a little wait is needed for the print to be rendered otherwise the file will be corrupted
driver.quit()
The format I'm trying to get it in can be viewed by opening the link (https://www.hsph.harvard.edu/nutritionsource/selenium/) on firefox and using the print option. Under format please select "simplified".
Is there any way this can be done in the required format?