Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsIn Python, navigate to the page with Selenium’s Chrome WebDriver, wait for the content you need, call driver.print_page(), and decode the returned base64 data into a PDF file. This is Selenium’s supported print workflow, but rendering is best effort: dynamic content, fonts, pagination, and backgrounds can vary by page and environment.
Save the current page as a PDF
Install Selenium with python -m pip install selenium and make Chrome available in the environment where the script runs. Selenium Manager handles driver setup in most supported cases; for Chrome sessions, Chrome and ChromeDriver still need to match at the major-version level. See Selenium’s Chrome-specific guidance.
As an Amazon Associate I earn from qualifying purchases.
The following complete example waits for the document navigation to finish, prints the current page, writes the PDF bytes, and always closes the browser:
import base64
from pathlib import Path
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
driver = webdriver.Chrome(options=options)
try:
driver.get("https://example.com")
WebDriverWait(driver, 20).until(
lambda d: d.execute_script("return document.readyState") == "complete"
)
pdf_base64 = driver.print_page()
Path("page.pdf").write_bytes(base64.b64decode(pdf_base64))
finally:
driver.quit()
print_page() prints the page currently loaded in the WebDriver session and returns PDF data; it does not save a file by itself. The base64 decoding and byte write turn that data into page.pdf. Selenium documents the workflow in its Print Page guide and Python Chromium WebDriver API.
#1 Best Overall
- BEST FOR SMALL BUSINESSES – Engineered for extraordinary productivity, the Brother DCP-L2640DW Monochrome (Black & White) 3-in-1 combines laser printer, scanner, copier in one compact footprint and delivers high-quality black & white prints
- FAST PRINTER WITH EFFICIENT SCANNING – Produces documents quickly with print speeds up to 36 ppm(2) and scan speeds up to 23.6/7.9 ipm(3) (black/color). A 50-page auto document feeder(4) allows for convenient, time saving multi-page scanning and copying
- FLEXIBLE CONNECTION OPTIONS – Easily navigate the changing demands of your business with secure multi-device connectivity via built-in dual-band wireless (2.4GHz / 5GHz) and Ethernet. Or connect locally to a single computer via USB interface
- BROTHER MOBILE CONNECT APP – Print, scan, and manage your wireless printer anytime, from almost anywhere from your mobile device. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(5)
- CHOOSE BROTHER GENUINE TONER – When it’s time to replace your toner, be sure to choose Brother Genuine TN830 or TN830XL replacement toner. And with Refresh EZ Print Subscription Service, you’ll never worry about running out of toner again and you’ll enjoy savings of up to 50%(6) on Brother Genuine Toner. Get started with Refresh today with a Free Trial(1)
Wait for the content that must appear
document.readyState == "complete" is a practical navigation baseline, not proof that an application has finished rendering. A single-page app may fetch data after navigation; images may load lazily; and a page may reveal content only after a user action. Wait for a meaningful, page-specific condition before calling print_page().
For example, replace the baseline wait with an expected element when the page has a reliable content marker:
Rank #2
- Wireless 3-in-1: Print | Copy | Scan
- Print up to 30 Pages Per Minute (BW, Letter)
- First Print Out in Approximately 5.3 Seconds (Letter)
- Auto 2-sided Printing
- Uses Toner 071 / 071 High-Capacity Toner
from selenium.webdriver.common.by import By
WebDriverWait(driver, 20).until(
lambda d: d.find_element(By.CSS_SELECTOR, "main article h1").is_displayed()
)
Choose a selector that represents the content needed in the PDF, and use a timeout appropriate for the site. No single wait condition guarantees that every application’s data, images, or animations are settled.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallChoose the printing route that fits
Selenium print_page()
Use this first when Selenium has already opened the page and its built-in print method meets your needs. It keeps navigation, any browser interaction, and PDF creation in one WebDriver flow. Selenium describes the result as best effort rather than a guarantee of identical output across sites and environments.
Rank #3
- FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for small teams printing, scanning and copying professional-quality black & white documents and reports. Perfect for 1-3 people
- WORLD'S SMALLEST LASER IN ITS CLASS – Precision laser printing, scanning, and copying that fits anywhere
- FAST PRINT SPEEDS – Up to 21 black-and-white pages per minute single-sided
- WIRELESS WITH SELF-RESET – Helps you stay connected
- EASILY COPY ID CARDS AND MORE – Copy both sides of ID cards or other small-size documents onto the same side of one sheet of paper
Chrome DevTools Protocol for print controls
If you need explicit PDF settings beyond the native Selenium method, Chrome’s Page.printToPDF protocol exposes controls including orientation, paper width and height, margins, scale, page ranges, headers and footers, CSS page-size preference, and background graphics. Selenium Python provides execute_cdp_cmd(cmd, cmd_args) for sending Chrome DevTools Protocol commands. Confirm which parameters your installed Chrome version supports before relying on them.
Chrome headless command line
When the page can be opened directly and requires no Selenium interaction, Chrome’s headless CLI can print to PDF with --headless --print-to-pdf; its documentation also describes suppressing the default header and footer. The CLI’s --timeout sets a maximum wait before capture, not confirmation that a particular application has finished rendering. Use WebDriver when the page requires actions before printing. See the Chrome Headless command-line reference.
Rank #4
- FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for offices printing, scanning and copying black & white brochures, business documents and presentations. Perfect for 1-5 people
- FASTEST TWO-SIDED PRINTING IN ITS CLASS – Up to 28 black-and-white pages per minute single-sided. Quickly finish multipage print projects with the fastest in-class two-sided printing speed
- DUAL-BAND WI-FI WITH SELF-RESET – Automatically detects and resolves connectivity issues
- STRONG SECURITY – Built-in security features help protect your printer from potential attacks
- PRINT FROM ANY DEVICE – Wireless printing from any mobile device, PC or tablet. Ethernet included. Works with Microsoft, Mac, AirPrint, Android, Chromebook and more.
Inspect the PDF and diagnose common problems
Open the generated file in the same kind of environment where it will be used. Check for missing content, unexpected page breaks, clipping, fonts, and backgrounds; rendering should be treated as best effort.
| Symptom | Likely cause | What to try |
|---|---|---|
| PDF is blank or missing recently loaded content | The page had not finished its application-specific rendering when print ran. | Wait for a content selector or another site-specific readiness condition before calling print_page(). |
| Lazy images or delayed sections are absent | Document navigation completed before those items were requested or displayed. | Trigger the page behavior needed to load them, then wait for the relevant content before printing. |
| Chrome session fails to start | The browser and ChromeDriver may be incompatible, including a major-version mismatch. | Check the installed Chrome and driver versions and follow Selenium’s Chrome setup guidance. |
| PDF layout, pagination, or background differs from expectations | Browser print rendering, page CSS, or defaults may affect the result. | Inspect the output; where supported, use the DevTools print parameters for paper size, margins, scale, ranges, headers and footers, CSS page-size preference, or background graphics. |
| Browser processes remain after an exception | The script exited without closing the WebDriver session. | Keep driver.quit() in a finally block so cleanup runs when navigation, printing, or saving fails. |
Or skip the browser setup
ScreenshotNeo can return a webpage PDF with one GET request. Its clean-shot flow accepts cookie or consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response includes X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents.
For the available PDF options and request parameters, see the ScreenshotNeo documentation. This Python example requests a PDF for the target URL:
Best Value
- FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for small teams printing professional-quality black-and-white documents and reports. Print speeds up to 35 ppm black.
- PROFESSIONAL PRODUCTIVITY – Proficiency with every print—bring your business to life with toner designed for sharp, professional-quality prints
- UPGRADED FEATURES – Fast printing, scanning and copying, auto 2-sided printing, a 250-sheet input tray and 50-sheet auto document feeder
- AWARD-WINNING RELIABILITY – Performance you can count on page after page, and always ready for the high demands of business
- WIRELESS PRINTING – Stay connected with our most dependable Wi-Fi, which looks for the best connection to stay online
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://example.com", "format": "pdf"},
timeout=90,
)
open("page.pdf", "wb").write(r.content)
ScreenshotNeo’s free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for the free plan.
Frequently Asked Questions
Does Selenium’s print_page() save a PDF file automatically?
No. It returns PDF data; decode the base64 result and write the bytes to a file, as shown above.
Can I use Selenium to print a page that needs clicks or other interaction first?
Yes. Navigate and perform the needed WebDriver interactions before calling print_page() on the current page.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




