Use Puppeteer’s page.screenshot() for a page image, element.screenshot() for a specific DOM element, and page.pdf() for a PDF. The key distinction is that PDFs use print styling by default, while screenshots capture the rendered page; choose full-page, clipped, or element capture to control the image area.
Set up a page and capture a screenshot
The basic workflow is to launch Chromium, open a page, navigate to the target URL, capture it, and close the browser. This ES-module example saves a full-page PNG and then captures a selected element. Puppeteer’s guide demonstrates navigation with waitUntil: 'networkidle2'; use an appropriate wait condition for the site you are capturing.
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 });
const main = await page.waitForSelector('main');
if (!main) throw new Error('Could not find the main element');
await main.screenshot({ path: 'main.png' });
} finally {
await browser.close();
}
Install Puppeteer in your project with npm install puppeteer if it is not already installed. This example uses documented Puppeteer calls; the official guide and API references are at Puppeteer’s screenshot guide and ScreenshotOptions.
Choose the screenshot area and output
Viewport, full page, or clip
page.screenshot()captures the page’s current viewport by default. SetfullPage: trueto capture the full page beyond the viewport.- Use
clipto capture a specific rectangular region. Specify itsx,y,width, andheightin the screenshot options. - Use
element.screenshot()when the desired output is a DOM element rather than a coordinate-based region. Puppeteer scrolls the element into view if necessary. The handle must still be attached to the DOM; a detached element causes an error.
Format, quality, and transparency
The documented default image format is PNG. You can set type to 'png', 'jpeg', or 'webp'. If you provide a file path, Puppeteer can infer the format from the path’s extension. The quality option ranges from 0 to 100 and applies to JPEG and WebP, not PNG. Set omitBackground: true to make the screenshot background transparent; its default is false.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- 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)
await page.screenshot({
path: 'region.webp',
type: 'webp',
quality: 80,
clip: { x: 20, y: 40, width: 800, height: 600 },
omitBackground: true
});
Save a file or work with bytes
Set path to write the image to a file. Without path, the screenshot is returned as a Uint8Array; base64 output can be requested with the matching encoding option.
const imageBytes = await page.screenshot({ fullPage: true });
For option details, see the Puppeteer screenshot options reference.
Save a page as a PDF
page.pdf() returns PDF bytes and can also write a file when you provide path. It generates the page using the print CSS media type by default. If you want screen styling instead, emulate screen media before calling it.
Rank #2
- BEST FOR HOMES & HOME OFFICES – Engineered for consistent, premium print quality, the Brother HL-L2405W Monochrome (Black & White) Laser Printer delivers sharp, crisp prints at an affordable price. Prints one-sided documents at speeds up to 30ppm(2)
- COMPACT, CONNECTED PRINTER – Flexible connection options make this an ideal printer for home use and at-home offices. Securely connect to multiple devices with built-in dual-band wireless (2.4GHz/5GHz) or locally to a single computer via USB interface
- BROTHER MOBILE CONNECT APP – Manage your printer remotely and print from your mobile device anytime, from almost anywhere. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(3)
- VERSATILE PAPER HANDLING – Enjoy seamless, reliable everyday printing with the 250-sheet paper tray(4) and a manual feed slot that enables printing on envelopes and specialty pape
- BROTHER IS AT YOUR SIDE – Backed by Brother with a 1-year limited warranty and free online, call, or live chat support for the life of your printer
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle2' });
// Optional: use screen styles instead of the default print styles.
// await page.emulateMediaType('screen');
await page.pdf({
path: 'page.pdf',
format: 'A4',
printBackground: true
});
} finally {
await browser.close();
}
PDF printing can modify colors. When exact colors matter, Puppeteer documents using the CSS property -webkit-print-color-adjust. For example, add this rule to the page’s stylesheet:
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →html {
-webkit-print-color-adjust: exact;
}
Configure PDF page size, margins, and content
Paper geometry and orientation
formatselects a named paper size and defaults to Letter. When supplied, it takes priority overwidthandheight.- Use
widthandheightwhen you need explicit dimensions rather than a named format. - Set
preferCSSPageSize: trueto give a CSS@pagesize priority over the PDF options. - Set
landscape: truefor landscape orientation. Otherwise the output is portrait. - Use
marginto set paper margins.
Backgrounds, scale, and page ranges
printBackground defaults to false, so set it to true if the PDF should include page background graphics and colors. scale defaults to 1 and accepts values from 0.1 to 2. Use pageRanges to restrict output, for example '1-5, 8, 11-13'.
Headers, footers, and fonts
Headers and footers are opt-in: set displayHeaderFooter: true and provide templates if needed. Puppeteer supports template classes for date, title, url, pageNumber, and totalPages. The 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().
Rank #3
- FAST PRINT SPEEDS: Print up to 19 pages per minute.
- COMPACT DESIGN: Space-saving, compact design fits anywhere in your home, school or small office.
- WIRELESS CONNECTIVITY: Print from almost anywhere in your workspace using your compatible mobile device.
- PAPER CAPACITY: Up to 150 sheets.
- SUSTAINABILITY: Uses less than 2 watts in Energy Saver mode.
await page.pdf({
path: 'selected-pages.pdf',
format: 'A4',
landscape: true,
margin: { top: '15mm', right: '12mm', bottom: '15mm', left: '12mm' },
printBackground: true,
pageRanges: '1-5, 8',
displayHeaderFooter: true,
headerTemplate: '<span class="title"></span>',
footerTemplate: '<span class="pageNumber"></span> / <span class="totalPages"></span>'
});
For the complete option set and template details, see Puppeteer’s PDFOptions reference.
Pick settings based on the output you need
| Output need | Setting to consider | What it changes |
|---|---|---|
| Capture the page beyond the visible viewport | fullPage: true |
Captures the full page rather than only the viewport. |
| Capture a coordinate-defined region | clip |
Limits capture to the rectangle you specify. |
| Capture a particular page element | element.screenshot() |
Targets an attached DOM element and scrolls it into view if needed. |
| Transparent image background | omitBackground: true |
Omits the default background for the screenshot. |
| Print layout in a PDF | Default PDF media mode | Uses print CSS media. |
| Screen layout in a PDF | page.emulateMediaType('screen') |
Applies screen media styling before generating the PDF. |
| Keep page colors in a PDF | printBackground: true and CSS -webkit-print-color-adjust |
Includes backgrounds and requests exact CSS color adjustment. |
| Use a chosen output location | path |
Writes the image or PDF to a file; omit it to receive bytes. |
Troubleshoot common capture problems
The target element cannot be captured
Wait for the selector with page.waitForSelector() before capturing. If the handle was obtained earlier, check that the element has not been removed or replaced; the screenshot API reports an error for a detached element.
The PDF looks different from the browser
PDF output uses print media by default, so print-specific CSS can change the layout. Call page.emulateMediaType('screen') before generating the PDF if screen styling is intended. If colors are missing or altered, enable printBackground and consider the documented -webkit-print-color-adjust: exact CSS rule.
Rank #4
- BEST FOR HOME OFFICES & SMALL TEAMS – Engineered for consistent, premium print quality, the Brother HL-L2460DW Monochrome (Black & White) Laser Printer produces documents that are clear, crisp, and easy to review and share, all at an affordable price
- COMPACT, CONNECTED, EXCEPTIONALLY EFFICIENT– Connect with built-in dual-band wireless (2.4GHz/5GHz), Ethernet, or to a single computer via USB interface. Prints at speeds up to 36ppm(2), plus automatic duplex printing saves time and reduces paper waste
- BROTHER MOBILE CONNECT APP – Manage your wireless printer remotely and print from your mobile device anytime, from almost anywhere. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(3)
- VERSATILE PAPER HANDLING – Tackle high-volume black & white printing with the 250-sheet capacity paper tray.(4) The manual feed slot enables printing on envelopes and specialty paper
- BROTHER IS AT YOUR SIDE – Backed by Brother with a 1-year limited warranty and free online, call, or live chat support for the life of your printer
The PDF paper size does not match CSS
Check the precedence of the options: format takes priority over width and height. If CSS @page dimensions should control the result, set preferCSSPageSize: true.
The screenshot format or file size is unexpected
Check the output extension and type together. The default is PNG; quality does not affect PNG output, so choose JPEG or WebP if you intend to use that quality setting.
Or skip the browser setup
ScreenshotNeo offers a one-request screenshot API if you do not want to manage Puppeteer and Chromium for a capture. This cURL example saves the returned image:
Best Value
- FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for small teams printing professional-quality black & white documents and reports. Perfect for 1-3 people
- WORLD'S SMALLEST LASER IN ITS CLASS – Precision laser printing 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
- PRINT FROM ANY DEVICE – Wireless printing from any mobile device, PC or tablet. Works with Microsoft, Mac, AirPrint, Android, Chromebook and more
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Its documented features include accepting cookie/consent banners and removing more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. An 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 screenshots.
Sign up for ScreenshotNeo’s free plan to try it without a card.
Frequently Asked Questions
Does Puppeteer return screenshot and PDF data if I do not set a path?
Yes. Screenshot and PDF calls return their generated bytes when no output path is provided.
Can I use PNG quality settings to reduce screenshot size?
No. Puppeteer’s documented quality option applies to JPEG and WebP, not PNG.
Recommended Free Tools
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.

