Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

Playwright Screenshot vs. page.pdf(): Which Should You Use?

Use page.screenshot() for viewport, element, clipped, or full-page images. Use page.pdf() for paginated documents, print CSS, paper sizes, and margins.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright’s page.screenshot() when you need an image of a page or element; use page.pdf() when you need a paginated PDF for printing or document-style sharing. A full-page screenshot is one tall image, not a PDF with paper-sized pages. The other key difference is that PDF generation uses print CSS by default.

Choose by the deliverable

Your need Use Why
Capture what is visible in the current browser viewport page.screenshot() Its default output is a viewport image.
Capture one element or a selected region page.screenshot() Screenshot options support element capture and clipping.
Save the entire scrollable page as one image page.screenshot({ fullPage: true }) It captures the full scrollable page rather than only the visible viewport.
Create a printable or paginated document page.pdf() It produces a PDF and exposes paper, margin, page-range, and print settings.
Make a PDF using screen styles rather than print styles page.pdf() after page.emulateMedia({ media: 'screen' }) PDF generation uses print media by default; emulate screen media first when that is the intended layout.
Preserve exact print colors page.pdf() with print CSS adjustments PDF colors are adjusted for printing by default; print CSS can request exact colors.

These behaviors and options are documented in the Playwright Page API and the Playwright Screenshots guide.

As an Amazon Associate I earn from qualifying purchases.

What each method produces

Screenshots produce image buffers

page.screenshot() returns an image buffer. The documented formats are PNG, JPEG, and WebP, with PNG as the default. Its options include full-page capture, clipping, scale, and background handling. Use it when the output will be viewed, embedded as an image, or used for visual review and comparison.

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

PDFs produce paginated documents

page.pdf() returns a PDF buffer. Its layout follows print CSS unless you emulate another media type first. Paper format or dimensions, margins, page ranges, and preferCSSPageSize give you control over document layout; preferCSSPageSize defaults to false.

#1 Best Overall
Brother DCP-L2640DW Wireless Compact Monochrome Multi-Function Printer, Copy, Scan, Duplex, Mobile Printing
  • 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)

A screenshot of a long page may be useful for visual inspection, but it has no paper-page layout or page breaks. If a reader needs to print the result or navigate it as a document, use PDF generation and check how the page’s print styles divide the content.

Runnable JavaScript examples

Install Playwright and its Chromium browser with npm install playwright and npx playwright install chromium. Save the following as capture.mjs, then run node capture.mjs. Each branch writes the requested artifact.

Rank #2
Canon imageCLASS MF273dw - Monochrome Wireless Laser Printer, Multifunction With Scanner, Copier, Auto Document Feeder, With 1 Year Limited Warranty, 30 PPM, Black
  • 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
import { chromium } from 'playwright';

const browser = await chromium.launch();
const page = await browser.newPage();

try {
  await page.goto('https://example.com', { waitUntil: 'networkidle' });

  const mode = process.argv[2] ?? 'screenshot';

  if (mode === 'screenshot') {
    await page.screenshot({ path: 'page.png', fullPage: true });
  } else if (mode === 'pdf') {
    await page.pdf({
      path: 'page.pdf',
      format: 'A4',
      printBackground: true
    });
  } else if (mode === 'screen-pdf') {
    await page.emulateMedia({ media: 'screen' });
    await page.pdf({ path: 'page-screen-styles.pdf', format: 'A4' });
  } else {
    throw new Error('Choose screenshot, pdf, or screen-pdf');
  }
} finally {
  await browser.close();
}

Run node capture.mjs screenshot for a full-page image, node capture.mjs pdf for a paginated PDF using print media, or node capture.mjs screen-pdf for a PDF rendered with screen media.

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

Capture just an element or region

For an element image, locate it and call screenshot on the locator:

Rank #3
Sale
HP Laserjet MFP M140w Wireless Black & White Printer, Print, scan, Copy, Fast speeds, Easy Setup, Mobile Printing, Best-for-Small Teams
  • 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
await page.locator('main article').screenshot({ path: 'article.png' });

For a selected viewport region, pass a clip rectangle to page.screenshot():

await page.screenshot({
  path: 'region.png',
  clip: { x: 40, y: 80, width: 800, height: 600 }
});

These are image captures; use PDF generation instead when the output needs page dimensions and pagination.

Rank #4
HP LaserJet MFP M235sdw | Monochrome | Laser Printer | All-in-One | Duplex
  • 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.

PDF settings that change the result

  • Media type: Print CSS is used by default. Call await page.emulateMedia({ media: 'screen' }) before page.pdf() if the PDF should use screen styles.
  • Paper and dimensions: Use format for a paper format such as 'A4', or set width and height. Margins, page ranges, and preferCSSPageSize also affect layout.
  • Backgrounds: printBackground defaults to false. Set it to true when background graphics are needed in the PDF.
  • Colors: Print color handling may differ from screen appearance. The API documents -webkit-print-color-adjust for requesting exact colors through print CSS.

Choose these settings for the intended document rather than assuming a PDF will match the browser viewport exactly.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

The PDF looks different from the page

That is expected when the page has print-specific CSS: PDF generation uses print media by default. If the intended output should follow screen styles, emulate screen media before calling page.pdf(). If print styling is intended, inspect the print layout and adjust the page’s print CSS.

Best Value
Sale
HP LaserJet Pro 3101sdw | Monochrome | Laser Printer | All-in-One | Duplex
  • 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

Background graphics are missing

PDF background printing is off by default. Set printBackground: true when backgrounds should appear.

Colors do not match the screen

PDF colors are adjusted for printing by default. If exact colors matter, use the documented print CSS adjustment -webkit-print-color-adjust and inspect the generated PDF.

A full-page screenshot is not suitable for printing

fullPage: true captures one image of the full scrollable page. It does not create paper-sized pages or page breaks. Use page.pdf() for a paginated document.

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

Repeated captures differ

Appearance can depend on the page’s CSS, fonts and assets, browser, and runtime environment. For meaningful comparisons, use the same browser and environment, then verify the output against the target page. This is especially important when fonts or page assets affect layout.

Or skip the browser setup

If you need an image capture without running Playwright yourself, ScreenshotNeo is a website screenshot API. This is an alternative for screenshots, not a replacement for Playwright’s PDF generation.

Quick Recap

Bestseller No. 2
Canon imageCLASS MF273dw - Monochrome Wireless Laser Printer, Multifunction With Scanner, Copier, Auto Document Feeder, With 1 Year Limited Warranty, 30 PPM, Black
Canon imageCLASS MF273dw - Monochrome Wireless Laser Printer, Multifunction With Scanner, Copier, Auto Document Feeder, With 1 Year Limited Warranty, 30 PPM, Black
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)
SaleBestseller No. 3
HP Laserjet MFP M140w Wireless Black & White Printer, Print, scan, Copy, Fast speeds, Easy Setup, Mobile Printing, Best-for-Small Teams
HP Laserjet MFP M140w Wireless Black & White Printer, Print, scan, Copy, Fast speeds, Easy Setup, Mobile Printing, Best-for-Small Teams
FAST PRINT SPEEDS – Up to 21 black-and-white pages per minute single-sided; WIRELESS WITH SELF-RESET – Helps you stay connected
$169.00
Bestseller No. 4
HP LaserJet MFP M235sdw | Monochrome | Laser Printer | All-in-One | Duplex
HP LaserJet MFP M235sdw | Monochrome | Laser Printer | All-in-One | Duplex
DUAL-BAND WI-FI WITH SELF-RESET – Automatically detects and resolves connectivity issues
$179.00

One GET request returns a screenshot:

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 documentation for request options. Before the shot, it accepts cookie or consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, 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 screenshots per month with no card; paid plans start at $5 for 3,000.

Sign up for ScreenshotNeo’s free plan.

How to decide reliably

  1. Decide whether the consumer needs an image or a document. Choose screenshot for an image; choose PDF for a paginated, printable deliverable.
  2. For an image, choose viewport, element, clip, or full-page capture. Remember that full-page means one tall image.
  3. For a PDF, decide whether print or screen CSS should govern the layout, then set paper, margins, page range, background, and color behavior as needed.
  4. Render the artifact in the browser and environment you intend to use, then inspect the actual output; page styling and runtime assets affect appearance.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.