Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

selenium save webpage as pdf python

from selenium import webdriver
import json

chrome_options = webdriver.ChromeOptions()
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)}
chrome_options.add_experimental_option('prefs', prefs)
chrome_options.add_argument('--kiosk-printing')
CHROMEDRIVER_PATH = '/usr/local/bin/chromedriver'
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=CHROMEDRIVER_PATH)
driver.get("https://google.com")
driver.execute_script('window.print();')
driver.quit()
Comment

PREVIOUS NEXT
Code Example
Python :: python random randint string 
Python :: Find and count unique values of a single column in Pandas DataFrame 
Python :: if main 
Python :: how to add textbox in pygame window 
Python :: python make file executable 
Python :: python getters and setters 
Python :: numpy array split 
Python :: matplotlib display graph on jupyter notebook 
Python :: remove dot from number python 
Python :: discord.py send image from url 
Python :: end python print with space 
Python :: swap variables in python 
Python :: save numpy array 
Python :: python check if there is internet connection 
Python :: python capitalize every first letter 
Python :: match python 3.10 
Python :: python not equal 
Python :: flask wtforms multiple select 
Python :: open file in python directory 
Python :: string remove in python 
Python :: seir model python 
Python :: loop indexing 
Python :: python execute function from string 
Python :: django only certain columns from database 
Python :: power function python 
Python :: create series in pandas 
Python :: python cholesky 
Python :: function for detecting outliers in python 
Python :: pandas rename column by dictionary 
Python :: python how to show package version 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =