The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Await the PDF operation itself, not just page navigation. In Puppeteer, wait for navigation, wait for any application-specific rendering condition, then call await page.pdf() and await the returned promise before writing or sending the bytes. Puppeteer’s PDF method waits for fonts by default, but neither network idle nor font readiness proves that charts, data, or custom components have finished rendering.
The correct completion sequence
HTML-to-PDF work has several different milestones. Treating them as one is the usual cause of blank pages, missing charts, and truncated files.
- Navigation finished: the selected lifecycle condition, such as Puppeteer’s
networkidle2, has resolved. - Fonts are ready: the browser has resolved the document’s font loading promise. Puppeteer documents this as enabled by default for PDF generation.
- Your application is ready: client-side data, charts, hydration, and custom components have rendered.
- PDF generation finished:
page.pdf()has resolved with the PDF bytes.
Only the final step means that the file is ready to save, upload, or return from an HTTP response.
Puppeteer: wait before exporting
Basic navigation and PDF generation
Puppeteer’s documented pattern is to await navigation with an appropriate lifecycle condition and then await page.pdf():
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- HP Papers is sourced from renewable forest resources and has achieved production with 0% deforestation in North America. Each ream is wrapped in a polyurethane coated paper wrapper to protect the cut sheets from moisture damage
- Sheet size – 8.5 x 11; Thickness – 20 pounds; Brightness – 92 bright white
- HP Copy&Print20 20 pounds printer paper is Forest Stewardship Council (FSC) certified and contributes toward satisfying credit MR1 under LEED (Leadership in Energy and Environmental Design)
- All HP Papers provide premium performance on HP equipment, as well as on all other printer and copier equipment; 100% satisfaction guaranteed; ColorLok technology provides more vivid colors, bolder blacks and faster drying
- Superior quality, reliability, and dependability for high-volume printing at home, at school and in the office; HP Copy&Print20 print and copy paper prevents yellowing over time to ensure a long-lasting appearance for added archival quality
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle2' });
const pdfBytes = await page.pdf({ path: 'output.pdf' });
console.log(`Wrote ${pdfBytes.length} bytes`);
} finally {
await browser.close();
}
The Page.pdf() method returns a Promise<Uint8Array>. Do not call fs.writeFile, send an HTTP response, or pass the value to another process until that promise resolves. The path option writes a file, while the returned bytes are useful when your application stores the document or streams it itself.
Why network idle is not enough
networkidle2 describes navigation and network activity. It does not know whether your application has received data, drawn a chart, mounted a component, or removed a loading overlay. A page can have no outstanding requests while JavaScript is still transforming data already in memory.
Give the page an explicit readiness contract. For example, set a flag only after every section needed in the PDF has rendered:
// Application code running in the page
async function renderReport() {
const data = await loadReportData();
renderCharts(data);
renderTables(data);
await document.fonts.ready;
window.readyForPdf = true;
}
renderReport();
Then wait for that condition with the wait-for-function facility in your installed Puppeteer version before generating the PDF. The exact method signature can vary by version, so check the API reference for the package you have installed. The important property is that the condition reflects your application’s actual completion state rather than an arbitrary delay.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows 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 reinstallRank #2
- 1 ream (500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
- Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
- Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
- Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
- Virgin copy paper providing professional quality results; acid-free to prevent yellowing
Font readiness
Puppeteer states that, by default, Page.pdf() waits for fonts to load. Its PDF options document waitForFonts as enabled by default and describe waiting for document.fonts.ready. If the page is in the background, font readiness may require bringing the page to the front. Font waiting prevents a common class of fallback-font and reflow problems, but it is not a signal that asynchronous application content is complete.
Make the page’s ready signal reliable
Use a visible, stable condition
Choose a condition that cannot become true prematurely. A suitable marker might be a report element containing a completed state:
<div id="report-status" data-state="loading"></div>
After all data and visual elements are complete, change it to data-state="ready". Your automation can wait for that selector or state, subject to the wait API and timeout used by your installed library.
Wait for charts and images deliberately
- Resolve the data request that feeds the chart before marking the page ready.
- Wait for chart libraries to finish their initial draw, rather than only waiting for the script file to load.
- For images that affect layout, wait until they have loaded and have known dimensions.
- Remove spinners, skeletons, and “loading” labels before setting the ready marker.
- Use a timeout so a failed data request produces an actionable error instead of an indefinitely hanging export.
Do not use a fixed sleep as the completion test
A fixed delay may be longer than necessary on a fast run and still too short on a slow one. It also hides the reason a page was not ready. A meaningful application condition is generally a stronger implementation choice, although the condition itself must be designed and tested by your application.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Rank #3
- 3 ream case (1,500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
- Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
- Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
- Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
- Virgin copy paper providing professional quality results; acid-free to prevent yellowing
Print CSS, screen CSS, and layout options
Puppeteer generates PDFs using print CSS by default. If the document is designed with screen styles and must retain them, select screen media before calling page.pdf():
await page.emulateMediaType('screen');
const pdfBytes = await page.pdf({
path: 'output.pdf',
printBackground: true,
format: 'A4',
preferCSSPageSize: true
});
Useful Puppeteer PDF options include format, landscape, margins, printBackground, preferCSSPageSize, pageRanges, path, timeout, and waitForFonts. The current reference lists a 30,000-millisecond default timeout; it is a configurable API default, not a guarantee that every page finishes within that time. Print output can adjust colors; Puppeteer points to the CSS property -webkit-print-color-adjust when exact color reproduction matters.
Playwright: await the buffer too
Playwright’s page.pdf() also returns the PDF buffer. Await it before writing or returning the document:
import { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle' });
// Insert your application-specific readiness wait here.
await page.waitForSelector('#report-status[data-state="ready"]');
await page.emulateMedia({ media: 'screen' });
const pdfBuffer = await page.pdf({
path: 'output.pdf',
format: 'A4',
printBackground: true
});
console.log(`Wrote ${pdfBuffer.length} bytes`);
} finally {
await browser.close();
}
Playwright likewise uses print media by default and documents selecting screen media before PDF generation when screen styling is required. The readiness rule remains application-specific: navigation completion and font behavior do not automatically cover every asynchronous renderer.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #4
- PREMIUM QUALITY: High-resolution full color printing on standard 8.5x11 inch sheets with professional-grade output and crisp, vibrant results
- VERSATILE OPTIONS: Choose from multiple stock materials including paper, card stock, laminated, and double-thick variants to suit your specific needs
- SAME-DAY SERVICE: Orders placed before 2 PM CST Monday through Friday qualify for same-day printing
- CUSTOMIZATION: Simply upload your PDF design for personalized printing
- AMERICAN MADE: Produced in USA facilities using premium stock, ensuring consistent quality and reliable delivery
Diagnose blank or incomplete PDFs
The file is empty or never appears
- Cause: the PDF promise was not awaited, or the process exited before the write completed.
- Fix: assign the result of
await page.pdf(...)and keep the browser or server process alive until the write or response finishes.
Text is present but charts are missing
- Cause: navigation reached its lifecycle condition before chart data or drawing completed.
- Fix: expose a readiness flag or DOM state after the chart’s final render and wait for it before calling PDF.
Fonts or line breaks differ
- Cause: font files were not ready, the page was backgrounded, or the print stylesheet differs from screen CSS.
- Fix: rely on Puppeteer’s default font wait, bring the page to the front if font readiness stalls, verify font responses, and explicitly select the intended media type.
The page times out
- Cause: a request never settles, a readiness marker is never set, or the configured PDF timeout is too short for the document.
- Fix: inspect failed requests and browser logs, make the application set an error state as well as a ready state, and choose a timeout appropriate for the document rather than hiding a permanent failure.
Colors or backgrounds are wrong
- Cause: print CSS is active or background printing is disabled.
- Fix: select screen media when appropriate, enable
printBackground, and apply-webkit-print-color-adjustwhere exact colors are required.
Performance, reliability, and cost decisions
Waiting for a semantic ready condition avoids both premature exports and unnecessary sleeps. Keep the condition narrow: wait for content that belongs in the PDF, not unrelated analytics, chat, or below-the-fold activity. Set bounded timeouts and log which stage failed—navigation, readiness, fonts, or PDF generation—so retries do not obscure the original fault.
For repeated exports, reuse browser processes carefully, isolate pages, and make each export’s readiness state independent. A cache or retry policy should not turn a partial document into a successful result. If conversion is handled by a hosted service or a separate asynchronous job API, use that provider’s documented job and status contract; there is no universal polling endpoint or completion event.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
ScreenshotNeo provides a website screenshot API and MCP server that can return screenshots or PDFs. A one-call request is:
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 documentation for PDF parameters and response handling. Equivalent clients are:
Recommended Free Tools
Best Value
- 5 ream case (2,500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
- Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
- Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
- Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
- Virgin copy paper providing professional quality results; acid-free to prevent yellowing
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Before capture, ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; 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 gives AI agents tools named take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to start.
Frequently Asked Questions
Should I wait for network idle or for a selector?
Use network idle for navigation, then wait for a selector, state, or flag that your application sets only after PDF-relevant content is rendered.
Does Puppeteer wait for fonts automatically?
Its documented PDF behavior enables waitForFonts by default and waits for document.fonts.ready; verify defaults against the Puppeteer version installed in your project.
Why does a successful PDF call still contain stale data?
A resolved PDF call only proves that PDF generation completed. It does not prove that an application-specific data request or renderer had finished; add and await an explicit readiness condition.
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.

