A client report with website screenshots needs three things to work: each capture labelled with its address and the time it was taken, an image format that doesn't bloat the PDF, and a way to lay out tall full-page captures without blank pages or unreadable thumbnails. We built such a report with Puppeteer and measured it. The short version: save the screenshots as JPEG, because Chrome copies JPEG bytes straight into the PDF while it re-compresses PNG and WebP; and show tall captures through page-sized windows, because a plain <img> taller than the page jumps to the next page and leaves its heading alone on a blank one.
This guide gives the two scripts we ran, the numbers, and the layout problems we hit.
What we built
The "client" is our own site, so nothing here describes anyone else's business. The report covers four pages of screenshotforweb.com: the home page, /tools, /pricing and /blog. Each page gets two captures:
- Desktop, full page, at a 1440-pixel-wide viewport. This shows everything a visitor can scroll to.
- Mobile, first screen, at 390 × 844 CSS pixels and a device pixel ratio of 2. This shows what a phone user sees before scrolling, which is usually what a client asks about.
Each capture is printed with its address and its capture time in UTC. A report that says "the pricing page" without a date is hard to use a month later, when the page has changed.
Step 1: capture the pages
This script visits each page, scrolls once so lazy-loaded images load before the full-page capture, and saves each capture three ways from the same page state: PNG, and JPEG and WebP at quality 80. It writes what it did to captures.json. We saved three formats only to compare them; a real report needs only the JPEG.
import { createRequire } from "node:module";
import { writeFileSync } from "node:fs";
const require = createRequire(import.meta.url);
const puppeteer = require("puppeteer");
const site = "https://screenshotforweb.com";
const pages = ["/", "/tools", "/pricing", "/blog"];
const devices = {
desktop: { width: 1440, height: 900, deviceScaleFactor: 1, fullPage: true },
mobile: { width: 390, height: 844, deviceScaleFactor: 2, isMobile: true, hasTouch: true, fullPage: false },
};
const browser = await puppeteer.launch();
const log = [];
for (const path of pages) {
for (const [name, { fullPage, ...viewport }] of Object.entries(devices)) {
const page = await browser.newPage();
await page.setViewport(viewport);
const started = Date.now();
await page.goto(site + path, { waitUntil: "networkidle2" });
if (fullPage) await page.evaluate(async () => {
for (let y = 0; y < document.body.scrollHeight; y += 800) { window.scrollTo(0, y); await new Promise(r => setTimeout(r, 100)); }
window.scrollTo(0, 0);
});
const file = `cap-${path === "/" ? "home" : path.slice(1)}-${name}`;
await page.screenshot({ path: `${file}.png`, fullPage });
await page.screenshot({ path: `${file}.jpg`, fullPage, type: "jpeg", quality: 80 });
await page.screenshot({ path: `${file}.webp`, fullPage, type: "webp", quality: 80 });
const { w, h } = await page.evaluate(() => ({ w: document.documentElement.scrollWidth, h: document.documentElement.scrollHeight }));
log.push({ url: site + path, device: name, file, capturedAt: new Date().toISOString(), cssSize: `${w}x${h}`, ms: Date.now() - started });
await page.close();
}
}
console.log("Chrome", await browser.version());
await browser.close();
writeFileSync("captures.json", JSON.stringify(log, null, 2));
console.table(log.map(({ file, cssSize, ms }) => ({ file, cssSize, ms })));
Puppeteer's quality option applies only to JPEG and WebP; its documentation says it is "not applicable to png images". The cssSize column is the page's full scroll size, not the size of the mobile image, which only covers the first screen. This is what our run printed:
Chrome Chrome/156.0.8078.47
┌─────────┬───────────────────────┬─────────────┬──────┐
│ (index) │ file │ cssSize │ ms │
├─────────┼───────────────────────┼─────────────┼──────┤
│ 0 │ 'cap-home-desktop' │ '1440x9643' │ 5000 │
│ 1 │ 'cap-home-mobile' │ '390x17286' │ 1483 │
│ 2 │ 'cap-tools-desktop' │ '1440x3228' │ 2209 │
│ 3 │ 'cap-tools-mobile' │ '390x5065' │ 1104 │
│ 4 │ 'cap-pricing-desktop' │ '1440x2272' │ 1791 │
│ 5 │ 'cap-pricing-mobile' │ '390x4801' │ 1085 │
│ 6 │ 'cap-blog-desktop' │ '1440x4302' │ 2694 │
│ 7 │ 'cap-blog-mobile' │ '390x10082' │ 1120 │
└─────────┴───────────────────────┴─────────────┴──────┘
The desktop home page is 9,643 pixels tall. That one capture decides most of the layout problems below.
Which image format keeps the PDF small
We put the same eight captures into the same A4 report three times, once per format, and printed each with page.pdf(). Then we asked pdfimages -list how each picture was stored inside the PDF.
| Format | Eight captures on disk | PDF size | How the PDF stores them | Time for page.pdf() |
|---|
| PNG | 4.15 MB | 4.05 MB | Re-compressed pixels (Flate) | 1,385 ms |
| JPEG, quality 80 | 2.43 MB | 2.55 MB | The original JPEG bytes (DCT) | 230 ms |
| WebP, quality 80 | 1.32 MB | 6.31 MB | Re-compressed pixels (Flate) | 1,514 ms |
The times are from one run each on a laptop, so treat them as a rough guide; the sizes are exact.
The surprise is WebP. It was the smallest on disk and gave by far the largest PDF, 2.5 times the JPEG one. The PDF file of Chrome's output names its producer as Skia/PDF m156; Skia is the graphics engine Chrome uses, and its PDF code explains the numbers. When an image's original encoded bytes are a suitable JPEG, Skia writes those bytes into the PDF unchanged with the DCTDecode filter. Every other image is decoded to raw pixels and compressed again with FlateDecode, which is lossless. A lossy WebP's compression noise is then stored losslessly, which costs more than the clean PNG did.
We checked the JPEG case directly: the home page image extracted from the PDF with pdfimages -j was byte-for-byte identical to cap-home-desktop.jpg. So for a report, JPEG is both the smallest choice and the one that doesn't change the picture again. Keep PNG for screenshots that will be compared pixel by pixel, not for PDFs.
Tall screenshots: three layouts, measured
A 1440 × 9,643 capture printed 186 mm wide (A4 minus 12 mm margins on each side) is about 1.25 metres tall. We tried three ways to fit it in.
Shrink it to one page. Scaled to fit a 225 mm tall box, the whole home page is 33.6 mm wide, 18% of the column. The report drops from 21 pages to 9, but none of the text can be read. Use this only as a thumbnail next to something readable.

Let it flow across pages. A plain <img> at full width is readable, and Chrome splits it between pages. To check whether rows go missing at the cuts, we printed a test image with a line and a label every 50 pixels. Nothing was lost or repeated: page 1 ended just after the line at pixel 2050 and page 2 began with the label for 2050. But the cut falls wherever the page ends, here through the middle of the label "4100".

The bigger problem showed up on page 1. With a heading and a caption above the screenshot, Chrome printed the heading alone and moved the whole image to page 2, leaving most of page 1 blank. We tried break-after: avoid on the heading, display: inline on the image and a flex wrapper; all three gave the same blank page.

The CSS Fragmentation specification explains why. It treats images as monolithic, meaning they contain no break points of their own. A browser first tries to break before a monolithic box, which here means after the heading. Only when a box doesn't fit even at the top of a fresh page may the browser "fragment the contents of monolithic elements by slicing". The specification also treats avoid values, which MDN's break-inside page lists for page, column and region breaks, as preferences that are dropped when there aren't enough break points. That matches what we saw: no CSS rule kept the heading with an image too tall for the page.
Show it through page-sized windows. The fix that worked is to never give Chrome an image taller than the space left on the page. We show the same image through a column of boxes with overflow: hidden, each as tall as a page (the first one shorter, to leave room for the heading), and shift the image up inside each box. That gave 5 pages for the home page instead of 6, with the heading and the screenshot together on page 1. The PDF still stores the image once: the five-page test PDF was 1.0 MB for a 0.96 MB JPEG.
Step 2: build the report
This is the report script we ran. It reads captures.json, shows desktop captures through windows, prints phones at 70 mm wide, and adds a footer with the report title and page numbers.
import { createRequire } from "node:module";
import { readFileSync } from "node:fs";
const puppeteer = createRequire(import.meta.url)("puppeteer");
const CONTENT_MM = { width: 186, height: 267 };
const HEADING_MM = 20;
function windows(src, widthPx, heightPx) {
const pxPerMm = widthPx / CONTENT_MM.width;
const tiles = [];
for (let top = 0, first = true; top < heightPx; first = false) {
const tall = Math.min(Math.floor((CONTENT_MM.height - (first ? HEADING_MM : 2)) * pxPerMm), heightPx - top);
tiles.push(`<div class="window" style="aspect-ratio: ${widthPx} / ${tall}">
<img src="${src}" style="margin-top: -${(top / widthPx) * 100}%"></div>`);
top += tall;
}
return tiles.join("");
}
const captures = JSON.parse(readFileSync("captures.json", "utf8"));
const stamp = (iso) => iso.replace("T", " ").slice(0, 16) + " UTC";
const sections = captures.map((c) => {
const src = `data:image/jpeg;base64,${readFileSync(`${c.file}.jpg`).toString("base64")}`;
const [width, height] = c.cssSize.split("x").map(Number);
const shot = c.device === "desktop" ? windows(src, width, height) : `<img class="phone" src="${src}">`;
return `<section>
<h2>${new URL(c.url).pathname} · ${c.device}</h2>
<p class="meta">${c.url} · captured ${stamp(c.capturedAt)}</p>
${shot}
</section>`;
}).join("");
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setContent(`<!doctype html><html><head><meta charset="utf-8">
<title>screenshotforweb.com: website screenshots</title><style>
body { font: 11pt/1.4 system-ui, sans-serif; margin: 0; }
section { break-before: page; }
h2 { font-size: 14pt; margin: 0; }
.meta { color: #555; font-size: 8.5pt; margin: 0 0 3mm; }
.window { overflow: hidden; }
.window img { display: block; width: 100%; }
.phone { width: 70mm; border: 1px solid #ccc; }
</style></head><body>${sections}</body></html>`);
await page.pdf({
path: "report.pdf",
format: "A4",
margin: { top: "12mm", bottom: "18mm", left: "12mm", right: "12mm" },
displayHeaderFooter: true,
headerTemplate: "<span></span>",
footerTemplate: `<div style="font-size:8px; width:100%; padding:0 12mm; display:flex; justify-content:space-between">
<span class="title"></span><span>Page <span class="pageNumber"></span> of <span class="totalPages"></span></span></div>`,
});
await browser.close();
It produced a 16-page, 2.51 MB PDF in which every page carries part of a screenshot and all 16 images are stored as JPEG. The same report with plain <img> tags was 18 pages, and four of them, one for each desktop capture, held nothing but a heading and an address.
A few details in it come straight from Puppeteer's PDFOptions documentation:
format defaults to letter, so set A4 if your clients are outside North America.
displayHeaderFooter defaults to false. The header and footer templates fill in elements with the classes date, title, url, pageNumber and totalPages. We passed an empty header so that only the footer prints.
printBackground defaults to false. Screenshots are images, not backgrounds, so they print either way, but any coloured boxes in your own report design need it set to true.
waitForFonts defaults to true, so the PDF waits for web fonts before printing.
What we'd put in every report
- The address and capture time on every screenshot, in UTC, written by the script rather than typed by hand.
- The viewport for each capture: "desktop, 1440 px wide, full page" or "mobile, first screen". A screenshot without its viewport invites the wrong comparison next month.
- JPEG at about quality 80 for anything going into a PDF. In our test it gave the smallest file and the PDF kept its bytes unchanged.
- Page-sized windows for tall captures, or a crop to the part of the page the report is about. Never a whole long page shrunk onto one sheet.
- The same pages, devices and settings every month, so this month's report can sit next to last month's.
If you'd rather not run Chrome yourself, our free screenshot tool captures desktop, laptop, tablet and mobile views as PNG, JPEG or WebP, and the API docs cover doing the same from a script.