October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Puppeteer Screenshot and PDF Examples: Full Pages, Elements, and Print Layouts

Runnable Puppeteer examples for full-page and element screenshots, image options, and PDFs with control over media mode and print layout.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Puppeteer’s page.screenshot() for a page capture, element.screenshot() for a specific DOM element, and page.pdf() for a PDF. The key choice for PDFs is that Puppeteer uses print CSS by default; call page.emulateMediaType('screen') first if you need the screen layout instead. These examples follow the Puppeteer 25.12.0 documentation; check the API references if you use another version.

Install Puppeteer and capture a full-page screenshot

Install Puppeteer in a Node.js project, then launch Chromium, navigate to the target page, save the image, and close the browser. The example uses networkidle2 as the navigation wait condition, as in the official guide. A page that continually makes network requests may need a different readiness strategy.

As an Amazon Associate I earn from qualifying purchases.

npm install puppeteer
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'networkidle2' });
  await page.screenshot({ path: 'page.png', fullPage: true });
} finally {
  await browser.close();
}

fullPage: true captures beyond the current viewport. Omit it, or set it to false, for a viewport screenshot. You can also use clip to define a rectangular capture region. The documented default output format is PNG; when saving with path, Puppeteer can infer the format from the file extension.

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

Choose format, quality, and transparency

  • PNG: the documented default. The quality option does not apply to PNG.
  • JPEG or WebP: choose the corresponding type when using those formats. The quality option ranges from 0 to 100 for supported lossy formats.
  • Transparent background: set omitBackground: true; it defaults to false.
await page.screenshot({
  path: 'page.webp',
  type: 'webp',
  quality: 80,
  fullPage: true,
  omitBackground: true
});

Save to disk or use the returned image bytes

When you provide path, Puppeteer writes the image there. Without a path, page.screenshot() returns image data (a Uint8Array by default). The screenshot API also supports base64 output through its encoding option.

#1 Best Overall
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
  • 1 ream (500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing

Capture one element with Puppeteer

Wait for the selector, then call screenshot() on its element handle. Puppeteer scrolls the element into view if needed before capturing it.

const element = await page.waitForSelector('main');
if (!element) throw new Error('Could not find main element');
await element.screenshot({ path: 'main.png' });

The handle must still refer to an element attached to the DOM. If the page replaces or removes that element between selection and capture, Puppeteer reports an error; wait for the current element again before retrying.

Rank #2
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
  • HP Papers is sourced from renewable forest resources and has achieved production with 0% deforestation in North America. Each ream is wrapped in a polyurethane coated paper wrapper to protect the cut sheets from moisture damage
  • Sheet size – 8.5 x 11; Thickness – 20 pounds; Brightness – 92 bright white
  • HP Copy&Print20 20 pounds printer paper is Forest Stewardship Council (FSC) certified and contributes toward satisfying credit MR1 under LEED (Leadership in Energy and Environmental Design)
  • All HP Papers provide premium performance on HP equipment, as well as on all other printer and copier equipment; 100% satisfaction guaranteed; ColorLok technology provides more vivid colors, bolder blacks and faster drying
  • Superior quality, reliability, and dependability for high-volume printing at home, at school and in the office; HP Copy&Print20 print and copy paper prevents yellowing over time to ensure a long-lasting appearance for added archival quality

Save a page as a PDF

page.pdf() returns PDF bytes and can write directly to a file with path. It generates the page using print CSS media by default. To use screen styling, emulate screen media before creating the PDF.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'networkidle2' });
  await page.pdf({ path: 'page.pdf', format: 'A4', printBackground: true });
} finally {
  await browser.close();
}

To produce a PDF using the screen media rules, insert this before page.pdf():

Rank #3
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
  • 3 ream case (1,500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing
await page.emulateMediaType('screen');

Set page size, orientation, and margins

  • format selects a paper format; its documented default is Letter. If set, it takes priority over width and height.
  • preferCSSPageSize: true gives the page’s CSS @page size priority over the PDF options’ paper dimensions.
  • landscape sets landscape orientation. Use margin to specify page margins.
  • pageRanges limits which pages are emitted; for example, '1-5, 8, 11-13'.

Control colors, backgrounds, and scale

PDF printing can modify colors. If exact colors are important, Puppeteer documents the CSS property -webkit-print-color-adjust as the way to request them. Background graphics are not printed by default; set printBackground: true to include them. The documented scale default is 1, and its accepted range is 0.1 to 2.

await page.addStyleTag({
  content: 'html { -webkit-print-color-adjust: exact; }'
});
await page.pdf({ path: 'page.pdf', printBackground: true, scale: 1 });

Add headers and footers

Headers and footers are opt-in through displayHeaderFooter. Their templates can use the documented classes date, title, url, pageNumber, and totalPages.

Rank #4
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
  • 5 ream case (2,500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing
await page.pdf({
  path: 'page.pdf',
  displayHeaderFooter: true,
  headerTemplate: '<span class="title"></span>',
  footerTemplate: '<span class="pageNumber"></span> / <span class="totalPages"></span>'
});

The API’s waitForFonts option defaults to true and waits for document.fonts.ready. The API reference notes that a page running in the background may need page.bringToFront() for font readiness.

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

Common problems and fixes

  • The screenshot is only as large as the viewport: set fullPage: true for the full page, or use clip when you want a specific region.
  • The PDF looks different from the browser: PDF generation uses print media by default. Call page.emulateMediaType('screen') first if the screen layout is intended.
  • PDF backgrounds or colors are missing or altered: enable printBackground for backgrounds and use -webkit-print-color-adjust: exact in the page’s CSS when exact colors are needed.
  • An element screenshot fails after selection: the element may have been detached from the DOM. Wait for the current matching element and capture its handle.
  • The expected font is absent in a PDF: Puppeteer waits for fonts by default, but a background page may need to be brought to the front with page.bringToFront().
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 through an API rather than managing Chromium, ScreenshotNeo accepts one GET request and returns an image or PDF. It accepts cookie and consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server exposes screenshot, page-info, and PDF tools for AI agents.

Example cURL request (see the ScreenshotNeo API documentation):

Best Value
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 8 Reams (4,000 Sheets), 92 Bright White, Great for Crisp Ink Printing
  • 8 ream case (4,000 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo and try 1,000 free screenshots a month, with no card required.

Quick Recap

Bestseller No. 1
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
1 ream (500 sheets) of 8.5 x 11 white copier and printer paper for home or office use; Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$6.97
Bestseller No. 2
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
Sheet size – 8.5 x 11; Thickness – 20 pounds; Brightness – 92 bright white
$6.97
Bestseller No. 3
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$21.96
Bestseller No. 4
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$29.14
Bestseller No. 5
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 8 Reams (4,000 Sheets), 92 Bright White, Great for Crisp Ink Printing
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 8 Reams (4,000 Sheets), 92 Bright White, Great for Crisp Ink Printing
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$53.19

Official Puppeteer references

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 *

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.

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
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.