To make a PDF that visibly contains website screenshots, capture the pages as images, place those images in an HTML report, then print that report to PDF with Playwright or Puppeteer. If you want a printable rendering of a live webpage rather than screenshot images, use the browser’s PDF method directly. Those are different outputs: page.pdf() does not automatically embed a screenshot.
Choose the right PDF workflow
First decide what the report needs to preserve:
- Screenshot evidence: Capture page or element images, then embed them in a report layout with captions, timestamps, URLs, or other context before rendering the layout as a PDF.
- Printable webpage: Navigate to the live page and generate a PDF from its rendered content. This is browser print output, not a PDF assembled from screenshot images.
Playwright and Puppeteer both provide screenshot and PDF APIs. Pick the library already used in your project, and check its documentation for the version you have installed. The official Playwright Page API documents page.screenshot() and page.pdf(); the Puppeteer PDF generation guide and Page.pdf() API reference describe the corresponding Puppeteer methods.
Generate a screenshot-based report with Playwright
This runnable Node.js example captures a page image, places it into a simple report page, and writes that report as a PDF. It uses Playwright’s Chromium browser. Install the package and browser first:
npm install playwright
npx playwright install chromium
Save the following as report.mjs and run it with node report.mjs:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
import { chromium } from 'playwright';
import { writeFile } from 'node:fs/promises';
const targetUrl = 'https://example.com';
const browser = await chromium.launch();
try {
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
await page.goto(targetUrl, { waitUntil: 'networkidle', timeout: 60000 });
const screenshot = await page.screenshot({ fullPage: true, type: 'png' });
const imageData = screenshot.toString('base64');
const capturedAt = new Date().toISOString();
const report = await browser.newPage();
await report.setContent(`
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Website screenshot report</title>
<style>
@page { size: A4; margin: 16mm; }
body { font: 12pt Arial, sans-serif; color: #222; }
h1 { font-size: 20pt; }
.meta { overflow-wrap: anywhere; color: #555; font-size: 9pt; }
img { display: block; width: 100%; height: auto; }
</style>
</head>
<body>
<h1>Website screenshot report</h1>
<p class="meta">URL: ${escapeHtml(targetUrl)}<br>Captured: ${capturedAt}</p>
<img alt="Screenshot of ${escapeHtml(targetUrl)}" src="data:image/png;base64,${imageData}">
</body>
</html>
`);
const pdf = await report.pdf({ format: 'A4', printBackground: true, margin: {
top: '16mm', right: '16mm', bottom: '16mm', left: '16mm'
} });
await writeFile('website-report.pdf', pdf);
} finally {
await browser.close();
}
function escapeHtml(value) {
return value.replace(/[<>&"']/g, (char) => ({
'&': '&', '<': '<', '>': '>',
'"': '"', "'": '''
})[char]);
}
The HTML entities shown inside the code block are for safe display in this article. In your .mjs file, use ordinary HTML characters in the template and the normal JavaScript escape map characters (&, <, >, and so on). Alternatively, build report HTML with a template file and populate it with safely escaped values.
The screenshot is held as a PNG buffer, encoded into a data URL, and embedded in the report. For multiple screenshots, capture each image and add an image-and-caption section for each one. A very tall full-page image may be scaled down substantially on a PDF page; use a larger paper size, split it into sections, or capture selected elements if legibility matters.
Generate a printable page PDF instead
If the goal is to print the page’s content rather than include a screenshot image, you can use Playwright’s PDF method directly:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
import { chromium } from 'playwright';
import { writeFile } from 'node:fs/promises';
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle', timeout: 60000 });
const pdf = await page.pdf({ format: 'A4', printBackground: true });
await writeFile('page.pdf', pdf);
} finally {
await browser.close();
}
Browser PDF generation uses print-media styling by default. If the PDF should reflect the page’s screen styles, emulate screen media before calling page.pdf(), as described in the Playwright API documentation and Puppeteer guide. For print output, add or adjust print CSS in the page or report so backgrounds, page breaks, and margins behave as intended.
Use Puppeteer if it fits your project
Puppeteer offers the same general workflow: capture a screenshot with its screenshot method, or create a PDF with page.pdf(). The API returns PDF bytes; write those bytes to a file or pass them to your application’s storage or response handling. Its PDF options include page dimensions and margins; consult the Puppeteer Page.pdf() reference for options supported by your installed release. Puppeteer’s PDF output also uses print CSS by default; emulate screen media when screen styling is required.
There is no universal winner established by the documented APIs alone. Consider your existing dependency, browser and deployment setup, and whether you need image evidence or print-rendered page content.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Practical capture and report choices
Wait for the right page state
Use a navigation wait condition appropriate to the site. A page can report that navigation has completed while client-side content, images, or charts are still loading. If the site has a known ready element, wait for that selector before capture; for pages with ongoing network activity, a fixed delay or a more specific readiness condition may be more reliable than waiting indefinitely for network idle.
Choose full-page or element screenshots
Use a full-page screenshot when the entire document is relevant. For a dashboard or a long page whose text must remain readable in the PDF, capture individual sections or specific elements and lay them out separately. Keep aspect ratios intact when scaling images and include a caption or source URL so each image can be interpreted later.
Plan the PDF layout
- Set paper size and margins using PDF options or
@pageCSS. - Use print styles for page breaks and report-only layout adjustments.
- Set
printBackground: truewhen background colors or images are part of the report design. - Check that image dimensions, text, captions, and page breaks remain readable in the resulting file.
Troubleshooting
The PDF contains no screenshot
A browser-generated PDF of the target URL prints its rendered page; it does not automatically include a separate screenshot file. Capture the image, embed it in report HTML, then print that report page.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
The screenshot is blank or incomplete
Check that navigation succeeded and the page’s content was ready before taking the screenshot. Wait for a site-specific selector when possible, and verify that the page is not showing a bot check, error page, or sign-in gate instead of the expected content.
The PDF looks different from the browser window
PDF output uses print media by default. Add print CSS for the intended document layout, or emulate screen media before generating the PDF if the screen presentation is required.
The report image is too small to read
A full-page screenshot can be much taller than the printable page. Capture smaller sections, use a larger paper size, or create multiple report pages rather than shrinking the entire image to fit one page.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteBest Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
The script times out or hangs
Some sites keep network requests open, so a network-idle wait may not be reached promptly. Prefer waiting for a meaningful page element or use an appropriate timeout and handle navigation failures. Close the browser in a finally block so it is cleaned up when an error occurs.
Or skip the browser setup
ScreenshotNeo can return a screenshot or PDF from one GET request. For a screenshot-based report, request an image and place it into your own report layout; for a PDF capture, request PDF output using the API’s supported parameters. See the ScreenshotNeo documentation for request options.
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Cookie and consent banners are accepted before capture and more than 60 known consent platforms, newsletter popups, and chat widgets are removed; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides screenshot, page-info, and PDF tools for AI agents. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month without a card.
Free tools Windows power users keep installed
One-click scans. No signup required.
Frequently Asked Questions
Does Playwright’s PDF method create a screenshot-based PDF?
No. It generates a PDF from the rendered page using print output. Capture and embed image files in report HTML when the PDF must contain screenshots.
Can I use Puppeteer for this workflow?
Yes. Puppeteer supports both page screenshots and PDF generation; choose it if it suits your existing project and browser setup.
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.

