Use Selenium’s WebDriver print-page command to turn the page currently open in headless Chrome into a PDF. Selenium returns encoded PDF data rather than saving a file for you, so decode that result and write it as binary. This guide uses Python, then shows the print settings, setup checks, and a direct Chrome alternative.
Print a rendered page with Selenium in Python
The example below navigates to a URL, enables headless Chrome, calls Selenium’s print-page API, decodes its base64 result, and saves page.pdf. Install Selenium with python -m pip install selenium; use a current Chrome or Chrome for Testing installation.
As an Amazon Associate I earn from qualifying purchases.
import base64
from pathlib import Path
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.print_page_options import PrintOptions
url = "https://example.com"
options = Options()
options.add_argument("--headless=new")
with webdriver.Chrome(options=options) as driver:
driver.get(url)
print_options = PrintOptions()
print_options.orientation = "portrait"
print_options.background = True
pdf_base64 = driver.print_page(print_options)
Path("page.pdf").write_bytes(base64.b64decode(pdf_base64))
print("Saved page.pdf")
The output is created in the process’s current working directory. Change the path in write_bytes to choose another location. The example enables backgrounds; remove that setting if you do not want printed background colors or images. Selenium’s API describes printing as best effort, not a guarantee of identical results across pages or environments. (Selenium Print Page; Python Chromium WebDriver API)
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Wait for page content before printing
driver.get() waits according to WebDriver’s page-load strategy, but a site may populate content later with JavaScript. If you need a particular element, wait for it explicitly before calling print_page:
#1 Best Overall
- PORTABLE SCANNER FOR USE ON-THE-GO — The fastest and lightest mobile single-sheet-fed compact document scanner in its class¹
- QUICK DOCUMENT SCANNING ― This Epson ultra-fast scanner scans a single page as quickly as 5.5 seconds²; Windows and Mac compatible
- VERSATILE PAPER HANDLING ― Portable scanner scans documents up to 8.5 x 72 in; Also easily digitizes receipts and ID cards to make accounting, bookkeeping, and organizing simpler
- INTUITIVE, HIGH-SPEED SOFTWARE — Epson ScanSmart Software³ is a smart tool allowing you to easily scan, review, and save; Stay organized easily with the help of this Epson scanner
- EASY SETUP — USB-powered connect to your computer for quick and simple scanning; No batteries or external power supply required to operate portable document scanner; Standard Connectivity: USB 2.0
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
WebDriverWait(driver, 20).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, "main"))
)
Place this inside the with block after driver.get(url). Choose a selector that indicates the content you actually need; visibility of one element cannot prove that every image, font, or asynchronous section has finished loading.
Adjust the PDF layout
Selenium’s PrintOptions supports orientation, page ranges, paper dimensions, margins, scale, background printing, and shrink-to-fit. Set only what the document needs and check the generated file: print CSS and page content affect the result.
Rank #2
- FAST SPEEDS - Scans color and black and white documents a blazing speed up to 16ppm (1). Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
- ULTRA COMPACT – At less than 1 foot in length and only about 1. 5lbs in weight you can fit this device virtually anywhere (a bag, a purse, even a pocket).
- READY WHENEVER YOU ARE – The DS-640 mobile scanner is powered via an included micro USB 3. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan.
- WORKS YOUR WAY – Use the Brother free iPrint&Scan desktop app for scanning to multiple “Scan-to” destinations like PC, Network, cloud services, Email and OCR. (2) Supports Windows, Mac and Linux and TWAIN/WIA for PC/ICA for Mac/SANE drivers. (3)
- OPTIMIZE IMAGES AND TEXT – Automatic color detection/adjustment, image rotation (PC only), bleed through prevention/background removal, text enhancement, color drop to enhance scans. Software suite includes document management and OCR software. (4)
- Orientation: use portrait for typical documents or landscape for wide tables and dashboards.
- Paper size: select a standard size such as A4 when the page should fit a known paper format.
- Margins: set top, bottom, left, and right margins when content is too close to an edge or needs more printable area.
- Scale and shrink-to-fit: adjust when text or wide elements are clipped or unexpectedly small.
- Page ranges: request selected pages, for example pages 2–4, when a full document is not needed.
- Backgrounds: turn background colors and images on when they carry information or are part of the intended layout.
Property names and accepted forms are binding-specific. Consult the Selenium print-page examples for your language rather than assuming Python syntax applies to Java or JavaScript.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteUse Chrome headless without Selenium
If you only need to open a URL and save a PDF, Chrome’s headless command line avoids writing WebDriver code. Run the Chrome executable available on your system:
Rank #3
- STAY ORGANIZED – Easily convert your paper documents into digital formats like searchable PDF files, JPEGs, and more.Power Consumption : 2.5W or less (Energy Saving Mode: 0.7W). Suggested Daily Volume : 500 scans..Does it contain liquid: no
- CONVENIENT AND PORTABLE –lightweight and small in size, you can take the scanner anywhere from home offices, classrooms, remote offices, and anywhere in between
- HANDLES VARIOUS MEDIA TYPES – Digitize receipts, business cards, plastic or embossed cards, reports, legal documents, and more
- FAST AND EFFICIENT – No technical hurdles or complicated setups here; easily scan both sides of a document at the same time, in color or black-and-white, at up to 12 pages-per-minute, and with a 20 sheet automatic feeder
- BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer
chrome --headless --print-to-pdf=output.pdf https://example.com
Chrome documents --no-pdf-header-footer to omit the print header and footer. It also documents --timeout to bound the wait before capture and --virtual-time-budget to advance time-dependent page behavior. Those timing options can help with delayed content, but a fixed wait does not ensure every dynamic site has finished rendering. See the Chrome Headless command-line reference.
Keep Chrome and ChromeDriver compatible
Selenium uses Selenium Manager by default in its bindings to help manage browser and driver setup. For Chrome-specific setup, Selenium’s documentation says Selenium 4 is compatible with Chrome v75 and greater and advises matching Chrome and ChromeDriver at least by major version. Avoid copying an old fixed driver version into a new project; browser releases change. (Selenium documentation; Selenium Chrome documentation)
Rank #4
- IRIScan Express, portable scanner : scans color and black and white documents a blazing speed up to 8ppm simplex. Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
- IRIScan Express mobile scanner is powered via an included micro USB 2. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan. USB cable provided. AC Adapter not provided and not needed.
- IRIScan flatbed scanner uses a simplex scanning mode allows for quick and straightforward scanning of single-sided documents. IRIScan with its full portable features is the ideal document scanners for computers.
- IRIScan document scanner : Versatile scanning capabilities, including scanning to Word, PDF, and Excel formats with companion software provided Readiris OCR
- Receipt scanner and card scanner with Additional features include scanning business cards directly to Outlook, photo scanning, and receipt scanning for efficient document management
For Chrome 115 and newer, Chrome and ChromeDriver releases are integrated through Chrome for Testing. Use its availability dashboard or JSON endpoints to obtain matching versions. If using a non-CfT Chrome binary, ChromeDriver’s guidance describes matching by the browser’s MAJOR.MINOR.BUILD version, with a milestone fallback where needed. Recheck the current guidance when setting up a build or updating a browser. (ChromeDriver version selection; Chrome for Testing downloads)
ChromeDriver is the standalone server Selenium uses to control Chrome and implements W3C WebDriver and WebDriver BiDi standards. Chrome for Testing supplies versioned browser and matching driver binaries for automation environments. (What is ChromeDriver?; Chrome for Testing binaries)
Best Value
- Scanner type: Document
- Connectivity technology: USB
- With Auto Scan Mode, the scanner automatically detects what you're scanning
- Digitize documents and images
Troubleshoot common PDF failures
- Chrome fails to start: verify Chrome is installed and available to Selenium Manager, or configure the browser binary and driver for your environment. Check that the installed Chrome and ChromeDriver major versions match.
- The PDF file is empty or invalid: make sure you decoded Selenium’s returned base64 data and wrote bytes, not the encoded text, to the file.
- Content is missing: wait for a page-specific element or known loading condition before printing. A page-load completion does not establish that all asynchronous content is ready.
- Content is clipped or too small: inspect paper size, orientation, margins, scale, and shrink-to-fit; also check whether the page’s print styles alter its layout.
- Background graphics are absent: enable the print option for backgrounds and confirm that the page itself supplies those backgrounds.
- Output differs between machines: Selenium calls print-page best effort. Compare the browser versions, page state, loaded resources, fonts, and print settings rather than expecting pixel-identical output by default.
- Headless CLI captures too early: adjust Chrome’s documented timeout or virtual-time budget for the page’s behavior, then inspect the output; a longer wait is not a universal completion signal.
Or skip the browser setup
ScreenshotNeo is a website screenshot API that also returns PDFs. Its one-call endpoint can be used when you do not need Selenium navigation or interaction before capture:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o page.pdf
See the ScreenshotNeo API documentation for options and response details. Cookie banners are accepted and removed before capture, along with known newsletter popups and chat widgets; those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server gives AI agents tools for screenshots, page information, and PDF capture. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for the free plan.
Choosing between Selenium and the Chrome CLI
Use Selenium when the workflow needs WebDriver navigation, page interaction, or structured print options before output. Use Chrome’s headless CLI when a URL-to-file command is sufficient. In either case, inspect PDFs from the pages and browser environments that matter to your application; the official Selenium API characterizes PDF generation as best effort.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Frequently Asked Questions
Does Selenium save the PDF file automatically?
No. The print-page call returns encoded PDF data; decode it and write the resulting bytes to a file.
Can I print only selected pages?
Yes. Selenium print options include page ranges; syntax varies by language binding.
Does Selenium’s print-page command work in headed Chrome?
Selenium’s browser windows and tabs guide specifies that the print-page operation requires Chromium to run headlessly.
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.




