To save a page already open in Selenium as a PDF, call WebDriver’s print-page command, decode the returned Base64 data, and write it to a .pdf file. In Chromium, use headless mode for printing. This creates a browser-printed PDF, not a screenshot image; use Selenium’s screenshot command if you need a raster image instead. Selenium’s print-page documentation describes the PDF workflow and its print options.
Save the current Selenium page as a PDF
The example below uses Selenium’s Python binding. It assumes Python, Selenium, and a compatible Chrome/Chromium WebDriver setup are installed. The browser must already be displaying the page you want to print.
Runnable Python example
from base64 import b64decode
from selenium import webdriver
from selenium.webdriver.common.print_page_options import PrintOptions
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
driver = webdriver.Chrome(options=options)
try:
driver.get("https://example.com")
# Replace this with a page-specific readiness condition if needed.
options_for_print = PrintOptions()
options_for_print.orientation = "portrait"
options_for_print.background = True
pdf_base64 = driver.print_page(options_for_print)
with open("page.pdf", "wb") as pdf_file:
pdf_file.write(b64decode(pdf_base64))
finally:
driver.quit()
Replace https://example.com with the page URL. The example sets portrait orientation and enables background printing; remove or change those settings to suit the page. Selenium’s print command returns PDF data encoded as Base64, so decode it before writing binary file contents. See Selenium’s print-page API guidance for the documented workflow and available options.
Wait for page-specific content before printing
A successful navigation does not guarantee that a single-page app, late-loading content, or web fonts are ready. Wait for a meaningful condition on the target page before calling print_page(). For example, use Selenium’s explicit waits for a known element that appears when the content is ready. There is no universal delay that works for every page, and the documentation does not prescribe one.
#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)
Choose PDF printing or a screenshot image
“Screenshot” can mean two different outputs. WebDriver screenshot capture produces an image; the print-page command produces a PDF representation using print layout. If you need searchable or paginated print output, use the PDF command. If you need a pixel image, capture a screenshot and convert that image to PDF separately if necessary. Selenium documents both page printing and screenshots; see printing and screenshots.
Set page size, margins, scale, and background
Selenium’s PrintOptions supports settings including orientation, page size, margins, scale, background printing, and shrink-to-fit. Choose the print configuration based on the page’s layout: landscape can help with wide tables, and enabling backgrounds may preserve colored panels that otherwise print without their background styling. Inspect the resulting PDF for clipping, unexpected page breaks, missing images, and text rendering. Exact output can vary by language binding, browser build, and operating system; identify those versions when reproducing a result.
Rank #2
- BEST FOR HOMES & HOME OFFICES – Engineered for consistent, premium print quality, the Brother HL-L2405W Monochrome (Black & White) Laser Printer delivers sharp, crisp prints at an affordable price. Prints one-sided documents at speeds up to 30ppm(2)
- COMPACT, CONNECTED PRINTER – Flexible connection options make this an ideal printer for home use and at-home offices. Securely connect to multiple devices with built-in dual-band wireless (2.4GHz/5GHz) or locally to a single computer via USB interface
- BROTHER MOBILE CONNECT APP – Manage your printer remotely and print from your mobile device anytime, from almost anywhere. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(3)
- VERSATILE PAPER HANDLING – Enjoy seamless, reliable everyday printing with the 250-sheet paper tray(4) and a manual feed slot that enables printing on envelopes and specialty pape
- BROTHER IS AT YOUR SIDE – Backed by Brother with a 1-year limited warranty and free online, call, or live chat support for the life of your printer
Handle Indian-language scripts and fonts
Indian web pages may use Devanagari, Tamil, or other scripts, and one font family does not necessarily cover every character. The final PDF depends on fonts available to the browser, the site’s CSS font stack, and whether its web fonts finish loading. Noto’s web guidance recommends selecting fonts for the writing systems used and explains that browsers fall back through the CSS family list when a font lacks a character. Its Hindi-and-Tamil example includes Noto Sans Devanagari, Noto Sans Tamil, Noto Sans, and Noto Sans Symbols 2. See Noto’s guidance on multilingual web fonts.
If the PDF shows boxes, blank glyphs, or wrongly shaped text, check the script on the page, whether its web fonts loaded before printing, and whether the browser environment has fonts with the required coverage. Check the PDF itself: a browser screenshot that looks correct does not prove the PDF has the same glyph coverage.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
- FAST PRINT SPEEDS: Print up to 19 pages per minute.
- COMPACT DESIGN: Space-saving, compact design fits anywhere in your home, school or small office.
- WIRELESS CONNECTIVITY: Print from almost anywhere in your workspace using your compatible mobile device.
- PAPER CAPACITY: Up to 150 sheets.
- SUSTAINABILITY: Uses less than 2 watts in Energy Saver mode.
For Linux Devanagari, a Chromium source change dated March 4, 2026 names Noto Sans Devanagari for standard and sans-serif defaults, Noto Serif Devanagari for serif, and Noto Sans Mono for fixed-width text. That is specific to Devanagari and Linux defaults; it does not establish defaults for every Indian script or every Linux image. See the Chromium source change. There is no universal font-package installation command established for all platforms and scripts, so verify the fonts in the browser environment you actually use.
When to use Chromium DevTools’ PDF command
For Selenium’s cross-binding print abstraction, use print_page(). If you need lower-level Chromium-specific control, Chrome DevTools Protocol provides Page.printToPDF, including controls such as paper orientation, margins, scale, and header/footer templates. Treat this as a Chromium DevTools route rather than the only way to print through Selenium. See the DevTools Protocol documentation.
Rank #4
- BEST FOR HOME OFFICES & SMALL TEAMS – Engineered for consistent, premium print quality, the Brother HL-L2460DW Monochrome (Black & White) Laser Printer produces documents that are clear, crisp, and easy to review and share, all at an affordable price
- COMPACT, CONNECTED, EXCEPTIONALLY EFFICIENT– Connect with built-in dual-band wireless (2.4GHz/5GHz), Ethernet, or to a single computer via USB interface. Prints at speeds up to 36ppm(2), plus automatic duplex printing saves time and reduces paper waste
- BROTHER MOBILE CONNECT APP – Manage your wireless printer remotely and print from your mobile device anytime, from almost anywhere. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(3)
- VERSATILE PAPER HANDLING – Tackle high-volume black & white printing with the 250-sheet capacity paper tray.(4) The manual feed slot enables printing on envelopes and specialty paper
- BROTHER IS AT YOUR SIDE – Backed by Brother with a 1-year limited warranty and free online, call, or live chat support for the life of your printer
Troubleshooting PDF output
| Symptom | Likely cause | What to check |
|---|---|---|
| Printing fails in Chromium | The browser is not running headless. | Run the Chromium session in headless mode, as required by Selenium’s browser guidance. See Selenium’s Chrome documentation. |
| The PDF is blank or missing late content | The page or its fonts had not finished loading. | Wait for a page-specific readiness condition before calling print_page(); do not rely on a fixed delay as a universal solution. |
| Some characters appear as boxes or blank glyphs | A required script font is missing, a web font did not load, or fallback coverage is inadequate. | Check the script’s font coverage and inspect the PDF output, not only a screenshot. |
| Content is clipped or paginated unexpectedly | Print layout, paper size, orientation, margins, or scale do not fit the page. | Adjust the relevant PrintOptions values and inspect the generated pages. |
| The saved file is unreadable | Base64 PDF data was written as text or not decoded. | Decode the string and open the output file in binary mode ("wb"), as in the example. |
Or skip the browser setup
If you need a screenshot image rather than Selenium’s printed PDF, ScreenshotNeo can return a website capture through one GET request. Its API returns PNG, JPEG, WebP, or PDF; it is a screenshot service, so choose PDF when that is the artifact you need.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for request options. It accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.
Quick Recap
Best Value
- FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for small teams printing professional-quality black & white documents and reports. Perfect for 1-3 people
- WORLD'S SMALLEST LASER IN ITS CLASS – Precision laser printing 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
- PRINT FROM ANY DEVICE – Wireless printing from any mobile device, PC or tablet. Works with Microsoft, Mac, AirPrint, Android, Chromebook and more
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.

