Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To save a rendered webpage as one tall PDF page with Selenium, use Python’s driver.print_page() with a custom page width and height sized to the content. Measure the rendered document, convert its CSS-pixel dimensions to centimeters, set the dimensions in PrintOptions, then decode and save the returned PDF data. This is browser printing to a custom-sized PDF sheet—not a guarantee of a screenshot-like result for every site, browser, or page length.

Use Selenium’s PDF print method with a custom page size

Selenium’s Python WebDriver API provides driver.print_page(print_options) to print the current page to PDF data. Its PrintOptions supports custom page dimensions, margins, scaling, backgrounds, orientation, shrink-to-fit, and page ranges. The custom size helper accepts dimensions in centimeters. See the Selenium 4.49.0 PrintOptions API reference and the Selenium Print Page guide.

The sample below assumes you already have a configured WebDriver and have navigated to the target URL. It measures the document after rendering, requests a sheet as wide and tall as the measured content, sets all margins to zero, and writes the base64-encoded PDF response to full_page.pdf.

import base64
from pathlib import Path
from selenium import webdriver
from selenium.webdriver.common.print_page_options import PrintOptions

# Configure a driver and navigate before running this section.
# Example:
# driver = webdriver.Chrome()
# driver.get("https://example.com")

width_px, height_px = driver.execute_script(
    "return [document.documentElement.scrollWidth, document.documentElement.scrollHeight]"
)

# CSS pixels are 1/96 inch; Selenium's custom page dimensions use centimeters.
px_to_cm = 2.54 / 96
options = PrintOptions()
options.page_width = width_px * px_to_cm
options.page_height = height_px * px_to_cm
options.margin_top = 0
options.margin_bottom = 0
options.margin_left = 0
options.margin_right = 0
options.background = True

pdf_base64 = driver.print_page(options)
Path("full_page.pdf").write_bytes(base64.b64decode(pdf_base64))

The sizing method is implementation guidance based on Selenium’s documented units, not an official Selenium recipe. Inspect the generated PDF’s page count and appearance in your target browser and driver. A page’s printed dimensions can differ from its screen dimensions because of print styles, layout changes, and browser behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Epson EcoTank ET-2800 Wireless Color All-in-One Supertank Printer - Black
  • INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
  • COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
  • ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
  • HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs

Make sure the page is ready before measuring

Navigation completing does not necessarily mean that all content you want is present. Pages may load data asynchronously, fetch images lazily, or reveal sections only as you scroll. Measure too early and the PDF can be correctly sized for an incomplete page.

  1. Navigate and wait for the relevant content. Use an explicit wait for a known element or condition that indicates the page has finished rendering the content you need.
  2. Trigger lazy-loaded sections. If content appears on scroll, scroll through the page and allow each section and its images to load before measuring.
  3. Measure after the layout settles. The example uses document.documentElement.scrollWidth and scrollHeight. If the result omits overflow or content, compare with document.body.scrollWidth and scrollHeight, and choose the measurements that represent the intended page.
  4. Print and inspect. Check the PDF’s page count, clipping, backgrounds, and text size. If the page reflows in print mode, the screen measurement may not match the print layout.

Understand the print options that affect the result

Custom dimensions determine the requested sheet size; they do not control every aspect of the printed layout. The options below have distinct effects, so change them deliberately and recheck the output.

Setting What it controls Practical use
page_width and page_height Custom sheet dimensions; custom values are in centimeters. Set these from measured content dimensions when requesting one tall sheet.
margin_top, margin_bottom, margin_left, margin_right Space around the printed page content. Set all four to zero for an edge-to-edge attempt; keep margins if the PDF needs a printable border.
background Whether CSS backgrounds are printed. Set to True if background colors or images are part of the desired output.
scale Print scaling; Selenium documents a range of 0.1 to 2. Use when adjusting content size, but test readability and clipping.
shrink_to_fit Whether content is reduced to fit the page. Consider it if fitting width matters more than preserving text size; test it with the selected width and scale.
orientation Portrait or landscape orientation. Choose based on the desired sheet layout; orientation alone does not make a page continuous.
page_ranges Which printed page ranges to include. Use when selecting pages from a multi-page print result, not as a substitute for custom sizing.

For example, the sample sets background = True and zero margins but leaves scale, orientation, shrink-to-fit, and page ranges at their defaults. If the output is too wide, shrink_to_fit may help, but it can make text smaller. If the content itself changes under print styles, dimensions measured from the screen may not be sufficient; inspect the output rather than assuming that the pixel-to-centimeter calculation guarantees a match.

Know what “without page breaks” can and cannot mean

A custom page height can avoid the ordinary pagination caused by printing onto a fixed-height Letter or A4 sheet, when the browser and driver accept and honor the requested dimensions. It is not a universal way to force every page into a single PDF page. The Selenium Python API describes printing as best effort: “The driver makes a best effort to return a PDF based on the provided parameters.” See the Selenium 4.49.0 remote WebDriver API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Epson EcoTank Photo ET-8550 Wireless Wide-Format All-in-One Tank Printer
  • CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
  • INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
  • PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
  • ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴
  • Print CSS can change layout. Stylesheets may hide elements, change widths, or force page breaks in print mode.
  • Fixed and sticky elements can behave differently. Their printed position or repetition may not match their on-screen appearance.
  • Very large pages have practical limits. The reviewed Selenium references do not establish a universal maximum custom page height, nor do they guarantee single-sheet output for arbitrarily long documents.
  • Browser and driver output can vary. Validate the exact browser/driver combination and page you intend to use; identical rendering across sites and browsers is not established by the API documentation.

If the page still splits, first confirm that the requested height reflects the content that is actually printed, then check for print-specific CSS and inspect whether your browser honored the custom dimensions. Do not increase the height blindly if doing so creates an unwieldy or unsupported PDF page.

PDF printing is not the same as a full-page screenshot

driver.print_page() produces PDF data through the browser’s print pipeline. Selenium’s documented save_screenshot() method saves a PNG of the current window; it is not documented there as a full-document PDF solution. A PDF can retain selectable text and print-oriented formatting, while a screenshot is raster image output. Choose according to whether you need a PDF document or an image of the page.

Chromium also documents a lower-level PDF command, Page.printToPDF, in its Chrome DevTools Protocol Page domain. That is a Chromium protocol route, not the same interface as Selenium’s standard Python driver.print_page() API.

Troubleshoot common output problems

The PDF contains only part of the page

Likely cause: Measurement happened before all content loaded, the measured element omitted overflow, or content appeared only after scrolling. Fix: wait for the target content, scroll through lazy-loaded sections, compare document and body dimensions, and measure again after the layout settles.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
HP Smart Tank 5000 Wireless All-in-One Ink Tank Printer, Scanner, Copier with 2 Years of Ink Included, Best-for-Home, Cartridge-Free, Refillable and AI-Enabled. (5D1B6A)
  • SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
  • INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
  • KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
  • PREMIUM SUPPORT - Strong technical expertise to solve issues faster
  • THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.

The PDF has more than one page

Likely cause: The requested dimensions do not match the printed layout, the browser did not apply the custom size as expected, or print CSS forces breaks. Fix: inspect the PDF’s actual page dimensions and print styles, then adjust measured width or height and test again. Selenium’s API only promises best-effort behavior.

Text is too small or content is clipped

Likely cause: Shrink-to-fit or scaling reduced content, or the custom width is insufficient. Fix: review scale and shrink_to_fit settings, compare the measured width with the printed layout, and regenerate the PDF. A width that fits more content may produce a page that is harder to read.

Background colors or images are missing

Likely cause: Background printing is disabled. Fix: set options.background = True and verify whether the site’s print styles retain those backgrounds.

Elements are missing or positioned differently

Likely cause: The site uses print-specific styles or fixed/sticky positioning, or content was not rendered before printing. Fix: inspect the target page’s print layout and wait for the required content; do not assume the screen view and print view share identical dimensions or element behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The PDF is unexpectedly large or the operation fails

Likely cause: A very long or wide page may exceed practical browser, driver, or PDF implementation constraints. The official references reviewed do not publish a universal size limit. Fix: reduce unnecessary content or use conventional pages if a single sheet is not reliable for the target document. Test with the actual page rather than relying on an assumed maximum.

Rank #4
NDYIN Portable Printers Wireless for Travel, N80 Bluetooth Thermal Printer
  • Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
  • No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
  • Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
  • Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
  • The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot image or PDF through an API rather than Selenium’s browser-print pipeline, ScreenshotNeo provides a website screenshot API and MCP server. Its API accepts a URL in one GET request and can return PNG, JPEG, WebP, or PDF. For the PDF format, use the documented request parameters described in the ScreenshotNeo documentation; this simple example shows the one-call request pattern and saves a WebP image:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie and consent banners as a visitor 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 the response identifies page verdict and billing status in headers. Its MCP server includes take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does Selenium’s custom page-size method guarantee a single-page PDF for any webpage?

No. Selenium documents best-effort printing, and print CSS, browser behavior, and very large page dimensions can affect the result.

What units should I use for Selenium custom PDF dimensions?

The custom page-size helper accepts centimeters. The example converts CSS pixels using 2.54 cm per 96 CSS pixels.

Can I use Selenium’s PNG screenshot method to make a full-page PDF?

The documented window screenshot method saves PNG output; it is separate from the PDF print method.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.