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

Use page.pdf() when you need a normal, selectable-text PDF; use page.screenshot({ fullPage: true }) when you need a visual capture, then convert that image with a separate PDF library. Playwright documents these as separate operations. A screenshot is not automatically converted into a PDF by the Page API.

Choose the right output first

Requirement Playwright approach Result
Selectable text, links and document pagination page.pdf() PDF rendered with print CSS by default
A visual copy of the page exactly as captured page.screenshot(), then an image-to-PDF workflow PDF pages containing rasterized images
Entire scrollable page as an image page.screenshot({ fullPage: true }) One full-page PNG or JPEG
Command-line operation playwright-cli pdf or playwright-cli screenshot File written by the CLI

PDF export through the Page API is a Chromium workflow. Screenshot capture is documented across Playwright browser contexts, while page.pdf() is the direct document-export method.

Save a page as a selectable-text PDF

Install Playwright, launch Chromium, navigate to the page, and provide a file path to page.pdf(). The returned value is also a PDF buffer, so you can stream it or store it yourself when you omit path.

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'networkidle' });

  await page.pdf({ path: 'page.pdf' });
  await browser.close();
})();

A relative path such as page.pdf is resolved from the process’s current working directory. Use an absolute path if a scheduler, test runner or container may start your script elsewhere.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Epson Workforce ES-50 Compact & Lightweight Mobile Document Scanner
  • 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

Make the PDF use screen styling

page.pdf() uses print media CSS by default. If your site has a print stylesheet that hides navigation, changes colors or rearranges cards, switch to screen media before exporting. Background graphics are disabled by default, so enable them explicitly when the design depends on backgrounds.

await page.emulateMedia({ media: 'screen' });
await page.pdf({
  path: 'screen-styled.pdf',
  printBackground: true
});

This changes the CSS media query used for layout; it does not turn the PDF into a screenshot. Text remains represented as PDF text where Chromium can preserve it.

Control paper size, orientation and margins

Use a paper preset such as A4 or Letter, or supply explicit dimensions with units including px, in, cm and mm. Set margins as strings with units and use landscape for wide tables or dashboards.

await page.pdf({
  path: 'report.pdf',
  format: 'A4',
  landscape: false,
  margin: {
    top: '16mm',
    right: '14mm',
    bottom: '16mm',
    left: '14mm'
  },
  printBackground: true
});

Do not combine a paper format and explicit width/height unless you have a specific reason: define one sizing strategy so the resulting pagination is predictable.

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

Wait for fonts, images and application content

A fast goto() can finish before a client-rendered application has populated its content. Wait for a meaningful selector, a known delay, or an application-ready condition before calling pdf(). For images, wait for the browser’s image promises when the page loads them dynamically.

Rank #2
Sale
Brother DS-640 Compact Mobile Document Scanner, (Model: DS640)
  • 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)
await page.goto('https://example.com/report', { waitUntil: 'domcontentloaded' });
await page.locator('#report-ready').waitFor();
await page.evaluate(() => document.fonts.ready);
await page.pdf({ path: 'report.pdf', printBackground: true });

For pages that continue polling or loading analytics, waitUntil: 'networkidle' may never be the best readiness signal. Prefer a selector that represents the finished state.

Save a full-page screenshot

If the deliverable is an image, save it directly. fullPage: true expands the capture to the page’s full scrollable height rather than only the current viewport.

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
  await page.goto('https://example.com', { waitUntil: 'networkidle' });
  await page.screenshot({ path: 'full-page.png', fullPage: true });
  await browser.close();
})();

Omit fullPage for a viewport-only capture. The screenshot API can also return an in-memory buffer when no path is supplied.

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

Turn a screenshot into an image-based PDF

Playwright does not document a built-in screenshot-to-image-PDF conversion method. Capture the PNG or JPEG first, then use an image-to-PDF library or your operating system’s PDF pipeline. This preserves the visual pixels but sacrifices selectable text, normal text search and accessible document structure.

A practical workflow is:

  1. Set the viewport and wait for the page’s finished state.
  2. Capture with fullPage: true if the entire scrollable page is required.
  3. Pass the resulting image file or buffer to your chosen PDF-generation library.
  4. Set a page size and image scaling policy so a very tall screenshot is not shrunk into unreadable text.

If the consumer needs to copy text, search, add annotations or reflow pages, use page.pdf() instead.

Rank #3
Sale
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
  • 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

Use the Playwright CLI

The official CLI provides direct commands for both outputs:

playwright-cli pdf --filename=page.pdf
playwright-cli screenshot --full-page --filename=full-page.png

When you do not provide a filename, the CLI generates a timestamped file. Use the PDF command for a document PDF and the screenshot command when you intend to create an image-based PDF later.

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

Reliable capture patterns

Keep navigation deterministic

  • Use an explicit URL and a deliberate readiness condition.
  • Set a navigation timeout appropriate for the target rather than relying on an accidental default.
  • Close the browser in a finally block in production code so failures do not leave Chromium processes running.
  • Choose a fixed viewport, timezone and locale when output must be reproducible.

Handle lazy content

Full-page screenshots can expose sections that were never rendered because they were below the fold. Scroll or trigger the application’s lazy-loading behavior before capture, then wait for the final content selector. A PDF generated before those sections exist will also omit them.

Prevent clipped or unexpected pages

  • Inspect print-specific CSS, especially display: none, fixed positioning and page-break rules.
  • Use printBackground: true when colored panels or background images carry meaning.
  • For wide tables, use landscape: true or a wider explicit page size.
  • Use print CSS such as break-inside: avoid carefully; preventing every break can create large blank areas.

Python and Node.js alternatives

The Page API is available from Playwright language bindings. The following Python example writes a selectable PDF and applies screen media:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://example.com", wait_until="networkidle")
    page.emulate_media(media="screen")
    page.pdf(path="page.pdf", print_background=True)
    browser.close()

In Node.js, the equivalent asynchronous call is:

import { chromium } from 'playwright';

const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.pdf({ path: 'page.pdf', format: 'Letter' });
await browser.close();

Install the browser binaries required by your Playwright version and run these examples in an environment where Chromium can start. Containers may require the dependencies documented for that distribution.

Rank #4
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
  • 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
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The PDF is blank

Check that navigation succeeded, the URL is reachable from the capture environment, and the application has rendered its content before export. Replace a broad network-idle wait with a ready selector and log page errors. Authentication redirects can also leave you exporting the login page.

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

Background colors or images are missing

Set printBackground: true. If the layout still differs, remember that print media is the default; call page.emulateMedia({ media: 'screen' }) before exporting.

The PDF looks different from the browser

Print CSS, viewport dimensions, fonts and animations can all change the result. Fix the viewport, wait for document.fonts.ready, disable or finish animations, and choose screen media when that is the intended design.

The page is cut off

For an image, add fullPage: true. For a PDF, inspect paper size, margins, overflow styles and print page-break rules. A PDF is paginated; it cannot represent an infinitely tall page as one normal sheet without choosing a custom height.

PDF export fails in a non-Chromium project

The Page API PDF workflow is Chromium-based. Run the PDF step with Chromium even if your broader test suite also uses another browser engine.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
  • Scanner type: Document
  • Connectivity technology: USB
  • With Auto Scan Mode, the scanner automatically detects what you're scanning
  • Digitize documents and images

The script hangs

Long-lived connections, service workers and analytics can prevent network-idle conditions. Use a selector or application event as the readiness signal, set explicit timeouts, and close the browser after errors.

Or skip the browser setup

ScreenshotNeo provides a single HTTP request for a screenshot or PDF. Its capture process accepts cookie and consent banners like a visitor, then removes more than 60 known consent platforms, newsletter popups and chat widgets before the shot; each cleanup step can be disabled. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and each response identifies the result with X-Page-Verdict and X-Billed headers. It also offers an MCP server with take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.

Use the API base endpoint and your access key:

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

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

See the ScreenshotNeo documentation for the full parameter set, including PDF paper size, margins, page ranges, full-page capture, selectors, waits, custom CSS and JavaScript, headers, cookies, geolocation, caching, signed links, asynchronous webhooks and bulk capture. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.

Cost and operational considerations

Self-hosted Playwright costs you the compute, browser maintenance and operational work of running Chromium. It gives you complete control over authentication, page scripts and post-processing. A hosted endpoint trades browser setup for per-capture billing and an HTTP integration. For either approach, cache stable pages, avoid unnecessary full-page captures, and record the URL, viewport, media mode and readiness condition alongside each artifact so you can reproduce a result.

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

Frequently Asked Questions

Can Playwright save a screenshot directly as a PDF?

Not through the documented Page API. Use page.pdf() for a document PDF, or save a screenshot and convert that image with a separate PDF workflow.

Does page.pdf() use screen or print CSS?

Print CSS is the default. Call page.emulateMedia({ media: 'screen' }) before exporting when the PDF should follow screen styling.

What does fullPage do?

fullPage: true captures the entire scrollable page for a screenshot instead of only the current viewport.

Quick Recap

SaleBestseller No. 3
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer; This product is not intended for scanning photographs on photo paper / photographic media
$153.00
Bestseller No. 4
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
Find our Software here : irislink.com/start; IRIScan Express is only compatible Windows platform and not macintosh
$129.00
Bestseller No. 5
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
Scanner type: Document; Connectivity technology: USB; With Auto Scan Mode, the scanner automatically detects what you're scanning
$75.00

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.