Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Use Puppeteer’s page.pdf() with a page box large enough for the rendered document, zero or small margins, print-specific CSS, and (when necessary) a carefully reduced scale. Puppeteer cannot guarantee that arbitrarily long HTML will be compressed into one readable sheet: the layout must physically fit the selected PDF page. The reliable approach is to create a print layout, measure it, then choose a normal page, a custom tall page, or a smaller scale.
What “one page” means in Puppeteer
page.pdf() generates a PDF using the print CSS media type by default. Chromium lays out the document inside the PDF page box, applies margins, and creates additional pages whenever content exceeds the available height. There is no unconditional option that losslessly shrinks any document to one page.
A one-page PDF is therefore possible only when the rendered content—including margins, borders, images, tables, generated content and late-loaded components—fits the chosen width and height. If the document is much taller than a sheet of paper, forcing it onto one page can produce unreadably small text. In that case, redesign the print view or use a custom taller page instead of relying on extreme scaling.
Use a print stylesheet to control the layout
Put print-only rules in @media print. Define the page dimensions with @page, reset the document’s margins, and remove elements that have no value in a printed copy.
#1 Best Overall
@media print {
@page {
size: 8.5in 11in;
margin: 0;
}
html, body {
margin: 0;
padding: 0;
}
.document {
break-after: avoid;
page-break-after: avoid;
}
.screen-only,
nav,
.cookie-banner,
.chat-widget {
display: none !important;
}
/* Use only when preserving exact colors is important. */
.document {
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
}
The example uses US Letter dimensions. Replace them with A4 or a custom size appropriate for your output. The page still has to fit after the browser lays out all content. Avoid fixed heights that clip text, wide tables that overflow horizontally, and unbroken strings that force unexpected wrapping.
Complete Puppeteer example
This script waits for navigation, lets the application finish rendering, and then creates a PDF using the CSS page size. Save it as an ES module such as print-one-page.mjs.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com/document', {
waitUntil: 'networkidle2'
});
// Wait for content that your application renders after navigation.
await page.waitForSelector('.document');
await page.pdf({
path: 'document-one-page.pdf',
preferCSSPageSize: true,
printBackground: true,
margin: { top: '0', right: '0', bottom: '0', left: '0' },
scale: 1
});
await browser.close();
Install Puppeteer with your project’s package manager, then run the file with Node.js. The networkidle2 navigation condition is useful for pages that load several resources, but it is not an application-ready signal by itself. Keep the explicit selector wait (or replace it with your own ready flag) when content is rendered after the initial navigation.
Why preferCSSPageSize matters
When preferCSSPageSize: true is set, a CSS @page size takes priority over PDF width, height or format options. This gives your stylesheet one source of truth for the page geometry. If you omit it, a PDF option can override the dimensions you declared in CSS.
When to emulate screen media
Printing uses print media by default, so rules inside @media print apply and screen-only styles may disappear. If the document is intentionally designed for its screen appearance, call this before page.pdf():
await page.emulateMediaType('screen');
await page.pdf({
path: 'screen-styled.pdf',
preferCSSPageSize: true,
printBackground: true
});
Use screen media deliberately. For most invoices, reports and documents, a dedicated print stylesheet is easier to control and more predictable.
Rank #2
How to make a long document fit one page
- Start with the intended paper size. Set
@pageto Letter, A4 or another real output size and begin with zero PDF margins. - Design a print-only layout. Hide navigation, consent notices, chat controls and decorative elements. Reduce excessive padding and line-height, and remove unnecessary headers and footers.
- Make CSS the authority. Keep
preferCSSPageSize: truewhen@pagedefines the dimensions. - Check content that changes height. Wait for images, fonts and client-rendered sections. Give images explicit dimensions where possible so late loading does not change pagination.
- Reduce scale gradually. Puppeteer accepts values from
0.1to2. Try values just below1, such as0.95or0.9, and inspect the resulting text at normal zoom. - Choose a taller page when necessary. If the content is substantially longer than Letter or A4, a custom tall page preserves readability better than shrinking everything.
Scale changes the size of the rendered page; it does not intelligently reflow a complex document. A lower value may make a one-page PDF technically possible while making body text, labels and accessibility-related reading impractical. Treat one-page output as a design requirement, not merely a command-line switch.
Page size, margins and scale options
| Approach | Best use | Advantages | Trade-offs |
|---|---|---|---|
| Normal Letter or A4 | Reports designed for ordinary printing | Works with common printers and viewers; readable text | Long content creates additional pages |
| Custom tall page | Receipts, posters or single-sheet exports | Keeps larger type and avoids arbitrary page breaks | Less convenient to print; some viewers and printers may handle it differently |
Reduced scale |
Content is only slightly too tall | Often fits without changing the document structure | Text and controls become smaller; values below 1 may be hard to read |
PDF margins consume space inside the page box. A CSS margin, element padding, border, or fixed header can consume additional space even when PDF margins are zero. Check all of them when a document unexpectedly spills onto a second page.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWaiting for dynamic content, images and fonts
Call page.goto() with an appropriate navigation condition before printing. For client-rendered applications, also wait for a meaningful selector or readiness promise:
await page.goto(url, { waitUntil: 'networkidle2' });
await page.waitForSelector('[data-print-ready="true"]');
await page.evaluate(() => document.fonts.ready);
Puppeteer’s PDF operation waits for fonts by default, but an application can still change the layout after navigation while it fetches data, expands components or inserts images. Waiting for your own ready signal prevents pagination from being calculated too early.
If a page contains lazy-loaded images, scroll or otherwise trigger the application’s loading behavior before printing. Verify that every image has loaded and that no skeleton, spinner or collapsed panel remains in the PDF.
Backgrounds, colors and print media
Set printBackground: true only when the document needs background graphics or colors. Without it, Chromium may omit background images and fills. Print CSS can also change colors for ink-saving behavior. The -webkit-print-color-adjust: exact declaration requests preservation of specified colors for supported content, but it does not fix layout problems or guarantee identical output on every viewer and printer.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →await page.pdf({
path: 'colored-document.pdf',
preferCSSPageSize: true,
printBackground: true
});
Inspect the same print layout before generating the PDF
Open the page in Chromium DevTools, switch the rendering emulation to print media, and inspect the layout at the exact CSS dimensions used by Puppeteer. Look for:
- Elements with fixed or minimum heights that exceed the page.
- Tables or code blocks whose long, unbroken strings force overflow.
- Images that have no dimensions or load after the PDF call.
- Large blank regions caused by flex, grid, or reserved advertising slots.
- Headers, footers, pseudo-elements, and generated content that appear only in print.
Inspecting the print media version is more reliable than judging the screen layout because page.pdf() uses print CSS unless you explicitly emulate screen media.
Common failures and fixes
“Puppeteer creates a second page”
The rendered content is taller than the available page box. Remove unnecessary print spacing, reduce margins, ensure late content has finished loading, and lower scale slightly. If the document is genuinely much taller, use a custom tall page or accept multiple pages rather than making the text microscopic.
“My @page size is ignored”
Set preferCSSPageSize: true. Also check that a conflicting format, width or height option is not being applied by another code path. Confirm that the stylesheet is loaded and that the rule is not invalid CSS.
“Zero margins still leave a large gap”
PDF margins are only one source of space. Inspect html, body, the outer document wrapper, print headers and fixed-position elements for margins, padding, borders and minimum heights.
“The PDF is missing colors or backgrounds”
Pass printBackground: true. If colors still differ, inspect print-media rules and consider -webkit-print-color-adjust: exact for the affected element. Some printers and viewers may still apply their own color handling.
Rank #4
“The PDF contains a spinner or incomplete data”
networkidle2 only describes network activity; it does not know when your application is ready. Wait for a selector, a framework-specific readiness event, or a page flag such as data-print-ready="true".
“Fonts change the pagination”
Make sure the font files are reachable and wait for document.fonts.ready when your application loads fonts dynamically. A fallback font can have different metrics and push the final line onto another page.
Recommended Free Tools
“Only part of the document appears”
Check for an ancestor with overflow: hidden, a fixed height, or a clipped scroll container. Remove those restrictions in the print stylesheet. Also verify that you did not accidentally set a restrictive pageRanges; an empty range prints all pages.
Performance and reliability considerations
Launching a browser for every PDF is slower and uses more memory than reusing a browser process. In a service, keep one controlled browser instance, create a fresh page per job, and close pages when finished. Limit concurrent jobs so several large documents do not exhaust CPU or memory.
Use explicit timeouts around navigation and readiness waits, and record the URL, selected page dimensions, scale and completion state for each job. A timeout should fail clearly rather than producing a partial file that looks valid. For remote pages, make sure the Chromium process can reach every stylesheet, font, image and API endpoint required for the final layout.
For ordinary paper output, favor readability and predictable page dimensions over a one-page requirement. For a dashboard or receipt that must be one continuous sheet, a custom page height is usually a better engineering choice than aggressive scaling. Keep text as PDF text rather than rasterizing it so users can search, select and copy it.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
- Used Book in Good Condition
Alternative: create a single-page image or PDF through an API
If your goal is a clean capture rather than controlling Chromium yourself, ScreenshotNeo provides a website screenshot API and MCP server. It can capture a full page, apply a custom viewport, wait for a selector, delay or network idle, and produce PNG, JPEG, WebP or PDF. Its cleanup step accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each step can be turned off.
Or skip the browser setup
Make one GET request with your access key and target URL. The API can return a PDF, and its other capture options cover full-page screenshots, custom page geometry and waiting behavior.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
For a PDF or other options, see the ScreenshotNeo documentation. The same request from Python is:
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
And in Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const data = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', data));
ScreenshotNeo reports whether a response was a clean shot and whether it was billed through the X-Page-Verdict and X-Billed headers. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed. An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients, so an AI agent can request the capture without you wiring browser automation.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteThe Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Create a free ScreenshotNeo account to try it.
FAQ
Can Puppeteer guarantee one page for any HTML?
No. The content must fit the selected page box, and extreme scaling can make the result unreadable.
Should I use pageRanges to force one page?
No. Page ranges select which pages to output; they do not reflow or shrink content. An empty range means all pages.
What is the safest first change when a document barely overflows?
Remove unnecessary print spacing and use a small scale reduction while checking text readability at normal zoom.
Why does a custom tall page sometimes print poorly?
Printers and PDF viewers have different support for unusual page dimensions. Validate the PDF in the viewers and physical printers your users actually use.
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.

