DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk8 min

How to Generate a PDF Report from Website Screenshots with Node.js

Use Node.js browser automation to capture website screenshots, assemble them into an HTML report, and print the report to PDF—or generate a print-rendered page PDF directly.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To make a PDF report that visibly contains website screenshots, capture the pages with a browser automation library such as Playwright, place the resulting images in an HTML report, then print that report to PDF. A direct page.pdf() call instead creates a browser-rendered document; it does not automatically embed a screenshot image. Choose the method based on whether you need screenshot evidence or a printable version of the page.

Choose screenshot pages or a printable web page

Playwright and Puppeteer both support browser-generated PDFs, and their PDF output uses print styling by default. That is useful for printable page content, but it is different from inserting a captured screenshot into a report. For screenshot evidence, explicitly capture images and assemble them in a report layout. For a print-oriented rendering of a live page, use the browser’s PDF API directly.

As an Amazon Associate I earn from qualifying purchases.

  • Use screenshot images when the report needs a visual record of what the browser displayed, with captions, timestamps, or other report content.
  • Use the PDF API on the target page when you want a print-laid-out version of the page rather than an image embedded in a report.

The examples below use Playwright for capture and PDF generation. If your project already uses Puppeteer, its equivalent PDF API is covered afterward.

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

Generate a PDF containing screenshots with Playwright

Install Playwright and its browser in your project, then save this as report.mjs. The example captures two URLs, builds a simple HTML report with a heading and caption for each image, and asks Chromium to print the report to a PDF.

#1 Best Overall
Sale
Epson Workforce ES-50 Compact & Lightweight Mobile Document Scanner
  • PORTABLE SCANNER FOR USE ON-THE-GO — The fastest and lightest mobile single-sheet-fed compact document scanner in its class¹
  • QUICK DOCUMENT SCANNING ― This Epson ultra-fast scanner scans a single page as quickly as 5.5 seconds²; Windows and Mac compatible
  • VERSATILE PAPER HANDLING ― Portable scanner scans documents up to 8.5 x 72 in; Also easily digitizes receipts and ID cards to make accounting, bookkeeping, and organizing simpler
  • INTUITIVE, HIGH-SPEED SOFTWARE — Epson ScanSmart Software³ is a smart tool allowing you to easily scan, review, and save; Stay organized easily with the help of this Epson scanner
  • EASY SETUP — USB-powered connect to your computer for quick and simple scanning; No batteries or external power supply required to operate portable document scanner; Standard Connectivity: USB 2.0
import { chromium } from 'playwright';
import { mkdir, writeFile } from 'node:fs/promises';
import { pathToFileURL } from 'node:url';
import path from 'node:path';

const targets = [
  { url: 'https://example.com/', title: 'Example homepage' },
  { url: 'https://example.org/', title: 'Example page' },
];

const outputDir = path.resolve('report-assets');
const pdfPath = path.resolve('website-report.pdf');

await mkdir(outputDir, { recursive: true });
const browser = await chromium.launch();

try {
  const pages = [];
  for (const [index, target] of targets.entries()) {
    const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
    const response = await page.goto(target.url, {
      waitUntil: 'networkidle',
      timeout: 60000,
    });

    if (!response || !response.ok()) {
      throw new Error(`Navigation failed for ${target.url}: HTTP ${response?.status() ?? 'no response'}`);
    }

    const imagePath = path.join(outputDir, `page-${index + 1}.png`);
    await page.screenshot({ path: imagePath, fullPage: true });
    pages.push({ title: target.title, url: target.url, imagePath });
    await page.close();
  }

  const report = await browser.newPage();
  const sections = pages.map((item) => `
    <section>
      <h2>${escapeHtml(item.title)}</h2>
      <p>${escapeHtml(item.url)}</p>
      <img src="${pathToFileURL(item.imagePath).href}" alt="Screenshot of ${escapeHtml(item.title)}">
    </section>`).join('n');

  await report.setContent(`
    <!doctype html>
    <html><head><meta charset="utf-8">
    <style>
      @page { size: A4; margin: 14mm; }
      body { font: 12px Arial, sans-serif; color: #222; }
      section { page-break-after: always; }
      section:last-child { page-break-after: auto; }
      img { display: block; width: 100%; height: auto; }
      h2 { margin-bottom: 4px; }
      p { overflow-wrap: anywhere; }
    </style></head><body>
    <h1>Website screenshot report</h1>
    ${sections}
    </body></html>`);

  await report.pdf({ path: pdfPath, format: 'A4', printBackground: true });
  await report.close();
  console.log(`Wrote ${pdfPath}`);
} finally {
  await browser.close();
}

function escapeHtml(value) {
  return String(value).replace(/[&<>"']/g, (char) => ({
    '&': '&amp;', '<': '&lt;', '>': '&gt;',
    '"': '&quot;', "'": '&#39;'
  })[char]);
}

Run it with node report.mjs. The script writes website-report.pdf and keeps the PNG files in report-assets. It uses networkidle as a starting point, not a guarantee that every site has finished rendering; pages with ongoing network activity or delayed content may need a different wait strategy.

For a minimal single-page capture, Playwright’s documented pattern is await page.screenshot({ path: 'screenshot.png' }). Its page.pdf() method returns a PDF buffer when no output path is supplied. See the Playwright Page API for the exact API reference.

Make the report layout dependable

  • Set a viewport before capture so screenshots have consistent dimensions.
  • Use full-page capture when the entire document is needed; use a regular viewport screenshot when the visible browser area is the evidence you want.
  • Keep the page-break rules in the report stylesheet if each screenshot should start on a new printed page.
  • For very tall screenshots, consider whether scaling the entire image to fit a paper width makes text too small. Splitting a capture or using a landscape page may produce a more readable report.
  • For reports built from untrusted titles or URLs, escape all inserted text and avoid placing untrusted values into HTML attributes without appropriate escaping.

Print a page directly instead of embedding a screenshot

If the desired output is the page’s print layout rather than a screenshot image, navigate to the page and call page.pdf() without first capturing a PNG. To use screen CSS in Playwright, emulate screen media before generating the PDF:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const page = await browser.newPage();
await page.goto('https://example.com/', { waitUntil: 'networkidle' });
await page.emulateMedia({ media: 'screen' });
await page.pdf({ path: 'page.pdf', format: 'A4', printBackground: true });

Without screen emulation, PDF generation uses print media styling by default. Use print CSS when the output should behave like a document: control page breaks, margins, and which elements appear in print. The Playwright API documents the PDF method and media emulation: Page | Playwright.

Rank #2
Sale
Brother DS-640 Compact Mobile Document Scanner, (Model: DS640)
  • FAST SPEEDS - Scans color and black and white documents a blazing speed up to 16ppm (1). Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
  • ULTRA COMPACT – At less than 1 foot in length and only about 1. 5lbs in weight you can fit this device virtually anywhere (a bag, a purse, even a pocket).
  • READY WHENEVER YOU ARE – The DS-640 mobile scanner is powered via an included micro USB 3. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan.
  • WORKS YOUR WAY – Use the Brother free iPrint&Scan desktop app for scanning to multiple “Scan-to” destinations like PC, Network, cloud services, Email and OCR. (2) Supports Windows, Mac and Linux and TWAIN/WIA for PC/ICA for Mac/SANE drivers. (3)
  • OPTIMIZE IMAGES AND TEXT – Automatic color detection/adjustment, image rotation (PC only), bleed through prevention/background removal, text enhancement, color drop to enhance scans. Software suite includes document management and OCR software. (4)

Using Puppeteer instead

Use the library already established in your project unless a specific browser or deployment requirement dictates otherwise; the cited documentation does not establish a universal winner. Puppeteer’s Page.pdf() returns PDF bytes and supports options including page dimensions and margins. Its guide also describes PDF generation as print-media rendering by default. To request screen styling, emulate screen media first:

await page.goto('https://example.com/', { waitUntil: 'networkidle' });
await page.emulateMediaType('screen');
const pdfBytes = await page.pdf({
  path: 'page.pdf',
  format: 'A4',
  printBackground: true,
  margin: { top: '14mm', right: '14mm', bottom: '14mm', left: '14mm' },
});

For an image-based report in Puppeteer, the architecture is the same as in Playwright: capture with the screenshot API, then place those image files into report HTML before calling page.pdf(). Consult the Puppeteer PDF generation guide and the Page.pdf() API reference for option details. Exact options can vary by installed version, so check the documentation matching your dependency.

Wait for the right page state

A screenshot can be technically successful while capturing an incomplete page. Navigation completion alone may not mean that client-rendered content, fonts, or lazy-loaded images are ready. Choose a readiness signal appropriate to the site and verify the result visually.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • For content that appears after a known UI action or selector, wait for that selector before capturing.
  • For delayed but predictable rendering, wait for a short, bounded delay after navigation rather than relying on an unbounded wait.
  • For lazy-loaded content, scroll the page or otherwise trigger the relevant content before taking a full-page screenshot.
  • For pages that continuously poll or stream, a network-idle condition may never occur; wait for a meaningful page element instead.

Troubleshooting common failures

PDF has no screenshot images

page.pdf() prints the current page; it does not turn a previous screenshot into a PDF report automatically. Build a separate HTML report containing the captured image files, open that report in the browser, and print the report.

Rank #3
Sale
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
  • STAY ORGANIZED – Easily convert your paper documents into digital formats like searchable PDF files, JPEGs, and more.Power Consumption : 2.5W or less (Energy Saving Mode: 0.7W). Suggested Daily Volume : 500 scans..Does it contain liquid: no
  • CONVENIENT AND PORTABLE –lightweight and small in size, you can take the scanner anywhere from home offices, classrooms, remote offices, and anywhere in between
  • HANDLES VARIOUS MEDIA TYPES – Digitize receipts, business cards, plastic or embossed cards, reports, legal documents, and more
  • FAST AND EFFICIENT – No technical hurdles or complicated setups here; easily scan both sides of a document at the same time, in color or black-and-white, at up to 12 pages-per-minute, and with a 20 sheet automatic feeder
  • BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer

PDF looks different from the browser window

PDF generation uses print media by default. Add print-specific CSS for the intended document layout, or explicitly emulate screen media before generating the PDF if screen styles are required.

Capture misses content or shows a loading state

Replace a generic navigation wait with a wait for the site’s actual content or a known selector. If content is lazy-loaded, trigger it before capture. Inspect the screenshot files before diagnosing the PDF step; this separates capture problems from report-printing problems.

Images are missing from the report PDF

Check that the image paths resolve from the browser context that loads the report HTML. Use absolute file URLs or serve assets from a reachable local HTTP server. Ensure the files exist before calling setContent(), and inspect the report page before printing.

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

Text or images are clipped, tiny, or split awkwardly

Adjust the report’s paper size, margins, image width, and page-break CSS. A full-page screenshot scaled to a paper sheet can make small text unreadable; use multiple report pages or a larger paper orientation when needed.

Rank #4
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
  • IRIScan Express, portable scanner : scans color and black and white documents a blazing speed up to 8ppm simplex. Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
  • IRIScan Express mobile scanner is powered via an included micro USB 2. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan. USB cable provided. AC Adapter not provided and not needed.
  • IRIScan flatbed scanner uses a simplex scanning mode allows for quick and straightforward scanning of single-sided documents. IRIScan with its full portable features is the ideal document scanners for computers.
  • IRIScan document scanner : Versatile scanning capabilities, including scanning to Word, PDF, and Excel formats with companion software provided Readiris OCR
  • Receipt scanner and card scanner with Additional features include scanning business cards directly to Outlook, photo scanning, and receipt scanning for efficient document management

Navigation times out or returns an error

Check the target URL, network access from the machine running Node.js, and the response status. Some sites block automated browsing or require authentication. Increase a timeout only when the page legitimately needs longer; do not treat a timeout as proof that a screenshot was captured successfully.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost considerations

Browser capture launches a browser process and loads each target page, so avoid launching a new browser for every URL when generating a batch: reuse one browser and create or close pages as needed. Set explicit navigation timeouts, keep image dimensions appropriate to the report, and close pages and browsers in a finally block so failures do not leave browser processes running. Validate the generated PDF in the deployment environment, because browser availability, fonts, network access, and page behavior can differ there.

The official APIs establish how to take screenshots and generate PDFs; they do not establish a universal runtime cost, speed, or reliability ranking between Playwright and Puppeteer. Budget for the compute and browser setup in your own environment and test against the sites and runtime you intend to use.

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

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server by Yorker Media. It removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and its API can return a PDF directly. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.

One GET request can return a PDF. For example, using cURL:

Best Value
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
  • Scanner type: Document
  • Connectivity technology: USB
  • With Auto Scan Mode, the scanner automatically detects what you're scanning
  • Digitize documents and images
curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com 
  -d format=pdf 
  -o report.pdf

See the ScreenshotNeo API documentation for authentication and supported parameters. Learn more at ScreenshotNeo, or sign up free for 1,000 screenshots a month, with no card.

Frequently Asked Questions

Can I use a screenshot image as the entire PDF page?

Yes. Put the image in an HTML page with print sizing and page-break rules, then generate the PDF from that page. For a direct image-to-PDF workflow, use a library that explicitly supports image placement.

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

Does a browser-generated PDF preserve selectable text?

A PDF printed from live page content may preserve text as document content, while a PDF made from screenshot images contains rasterized page visuals. The exact output depends on the page and rendering path.

Quick Recap

SaleBestseller No. 3
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer; This product is not intended for scanning photographs on photo paper / photographic media
$153.00
Bestseller No. 4
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
Find our Software here : irislink.com/start; IRIScan Express is only compatible Windows platform and not macintosh
$129.00
Bestseller No. 5
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
Scanner type: Document; Connectivity technology: USB; With Auto Scan Mode, the scanner automatically detects what you're scanning
$75.00

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.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
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.