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.
Choose format, quality, and transparency
- PNG: the documented default. The
qualityoption does not apply to PNG. - JPEG or WebP: choose the corresponding
typewhen using those formats. Thequalityoption ranges from 0 to 100 for supported lossy formats. - Transparent background: set
omitBackground: true; it defaults tofalse.
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
- 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 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.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →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
- 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
formatselects a paper format; its documented default is Letter. If set, it takes priority overwidthandheight.preferCSSPageSize: truegives the page’s CSS@pagesize priority over the PDF options’ paper dimensions.landscapesets landscape orientation. Usemarginto specify page margins.pageRangeslimits 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
- 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.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesCommon problems and fixes
- The screenshot is only as large as the viewport: set
fullPage: truefor the full page, or useclipwhen 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
printBackgroundfor backgrounds and use-webkit-print-color-adjust: exactin 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().
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
- 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
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.
Recommended Free Tools




