Use an application-owned “canvas ready” signal, wait for it after navigation, then call page.pdf() with deliberate media, background, sizing, and scale settings. Puppeteer cannot infer that a chart, animation, worker, or WebGL renderer has finished its final draw. A reliable PDF therefore combines browser-loading waits with a signal set by your own rendering code.
The reliable rendering sequence
A PDF capture has several independent readiness questions:
- Has the document navigated?
- Have data, images, and other resources needed by the drawing code loaded?
- Have fonts loaded?
- Has every relevant canvas received the frame you want to print?
networkidle2 helps answer the first two questions, and Puppeteer waits for fonts as part of its documented PDF flow. Neither proves that application rendering is complete. The page must expose that final state.
1. Add a page-owned readiness contract
Set a flag only after data is available and the final visible draw has run:
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
// In the application, after data is loaded and the final canvas draw has run:
window.__canvasReady = true;
For multiple canvases, set the flag only after all required renderers finish. If an animation is involved, decide which frame the PDF represents and stop or synchronize the animation before setting the flag.
2. Navigate, wait, and generate the PDF
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com/chart', { waitUntil: 'networkidle2' });
await page.waitForFunction(() => window.__canvasReady === true);
// Use this only when the PDF should use screen rather than print CSS.
await page.emulateMediaType('screen');
await page.pdf({
path: 'canvas-report.pdf',
printBackground: true,
preferCSSPageSize: true
});
} finally {
await browser.close();
}
The navigation, media emulation, and PDF options follow Puppeteer’s documented APIs. The readiness flag is your application’s contract, not a Puppeteer-provided canvas detector.
Print media versus screen media
page.pdf() uses the print CSS media type by default. That is appropriate when the page has a print-designed layout, but it can hide or restyle a canvas through @media print rules.
Choose intentionally
- Screen-faithful report: call
await page.emulateMediaType('screen')before generating the PDF. - Paper document: leave print media active and define the intended layout in print CSS.
Inspect print rules for display:none, changed dimensions, altered colors, or containers that collapse around the canvas. If exact colors matter, use -webkit-print-color-adjust: exact in the relevant CSS and enable printBackground: true for CSS background graphics. Print rendering can otherwise modify colors for paper output.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Configure paper, scale, and backgrounds
PDF options determine whether a correctly drawn canvas is visible at the expected size.
await page.pdf({
path: 'report.pdf',
format: 'A4',
landscape: true,
margin: { top: '12mm', right: '12mm', bottom: '12mm', left: '12mm' },
printBackground: true,
scale: 1,
preferCSSPageSize: true
});
When CSS should control the page
Use preferCSSPageSize: true when an @page rule expresses the authoritative paper size:
@page {
size: A4 landscape;
margin: 12mm;
}
.report {
break-inside: avoid;
}
Without that preference, choose a format such as A4, or explicit width and height, through PDF options. Margins, paper dimensions, and scale all affect fit. A canvas can be fully rendered yet clipped because its containing block exceeds the printable area.
Canvas dimensions, sharpness, and distortion
A canvas has an intrinsic bitmap coordinate space from its width and height attributes. CSS width and height only resize that bitmap for display; they do not add drawing detail and can distort the aspect ratio.
Recommended Free Tools
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Set backing dimensions deliberately
<canvas id="sales" width="1600" height="900" style="width:800px;height:450px"></canvas>
Here the drawing buffer is 1600×900 while the displayed canvas is 800×450. Choose a backing resolution suitable for the printed dimensions and the renderer’s memory budget. Avoid relying on CSS to enlarge a small source bitmap. Check the PDF at its actual intended paper size rather than judging sharpness from a browser screenshot.
Keep aspect ratios consistent
If the attributes and CSS dimensions use different ratios, circles become ellipses and text or lines appear stretched. Set both dimensions intentionally, or calculate the backing dimensions from the display size and desired device-pixel ratio before drawing.
Waiting for data, images, fonts, and workers
Use separate waits for separate dependencies:
- Navigate with an appropriate
waitUntilcondition, commonlynetworkidle2for pages that continue loading briefly. - Have the application load chart data and image assets used by the drawing code.
- Allow the final draw, worker message, or WebGL frame to reach the visible canvas.
- Set the readiness flag and wait for it with
page.waitForFunction.
Do not replace this contract with a fixed sleep. Rendering time varies with data size, CPU load, cache state, and animation timing. document.fonts.ready answers a font-loading question; it does not say that a chart has drawn.
Example with an explicit promise
// Application code
window.__canvasReadyPromise = renderChart().then(() => {
drawFinalFrame();
window.__canvasReady = true;
});
The capture script still waits on window.__canvasReady. This keeps the browser automation independent of the chart library while making the page responsible for knowing what “done” means.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Animation, workers, and multiple canvases
Animations
Choose a deterministic frame. Pause the animation, seek to a known timestamp, draw that frame, and then set the ready flag. Otherwise two PDF runs can capture different visual states even when navigation and network conditions are identical.
Workers and WebGL
If a worker produces the bitmap, signal readiness only after the message has been applied to the visible canvas. For WebGL, wait for the final render operation and any required resource uploads rather than merely waiting for the page to become idle.
Several charts
Track each renderer and expose one aggregate state:
const charts = ['revenue', 'users', 'retention'];
const finished = new Set();
function markChartReady(name) {
finished.add(name);
if (charts.every(chart => finished.has(chart))) {
window.__canvasReady = true;
}
}
Accessibility and searchable PDFs
Canvas is bitmap output. Its drawn bars, labels, and points are not independently exposed as semantic objects for assistive technology, and bitmap text is not reliably searchable or selectable. If the PDF must be understandable without the image, include an equivalent textual summary and, where appropriate, a data table in HTML next to the canvas.
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 minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
<figure>
<canvas id="revenue-chart" aria-describedby="revenue-summary"></canvas>
<figcaption id="revenue-summary">Revenue rose from $2.1M in Q1 to $2.8M in Q2.</figcaption>
<table>...equivalent values...</table>
</figure>
This gives the PDF a meaningful reading path even if the visual bitmap is unavailable.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Debugging blank, stale, or incorrect PDFs
The PDF is blank or shows an old frame
- Verify in the page that the canvas has been populated before calling
page.pdf(). - Confirm data and image assets used by the drawing code have loaded.
- Set the application-owned flag after the final draw, not when a request starts or a component mounts.
- For workers and animation, signal after the desired frame is actually visible.
- Do not treat
networkidle2or font readiness as canvas readiness.
Colors or layout differ from the browser
- Inspect
@media printfor hidden elements, changed dimensions, and alternate colors. - Use
emulateMediaType('screen')when screen CSS is the intended design. - Set
printBackground: truefor CSS backgrounds. - Use
-webkit-print-color-adjust: exactwhere exact color reproduction is required, then inspect the PDF rather than assuming it is identical.
The canvas is blurry or stretched
- Check intrinsic
widthandheightattributes, not only CSS sizes. - Render at sufficient backing resolution for the target printed dimensions.
- Keep intrinsic and CSS aspect ratios aligned.
- Review the PDF at its physical output size.
The canvas is clipped or split unexpectedly
- Inspect the canvas container’s dimensions and overflow.
- Reduce margins or choose a larger paper size when the printable area is too small.
- Use CSS page sizing with
preferCSSPageSizewhen the stylesheet owns the layout. - Apply deliberate page-break rules to surrounding content; do not assume a canvas will be split meaningfully across pages.
The result varies between runs
- Make data, animation frame, and readiness conditions deterministic.
- Wait for the actual draw instead of adding an arbitrary delay.
- Pin and verify the Puppeteer/Chromium version used in deployment; identical settings do not guarantee identical output across versions.
Performance and reliability practices
- Render only the backing resolution required by the PDF; oversized buffers increase memory and rasterization work.
- Reuse a browser process for batches, but create isolated pages and close them after capture.
- Keep the readiness flag scoped to the current document so a previous navigation cannot satisfy a later wait.
- Log navigation errors, readiness timeouts, canvas dimensions, selected media type, and PDF options.
- Inspect representative PDFs, including long pages, empty data, slow assets, and the largest chart.
- Use timeouts that reflect your application’s worst expected load and fail clearly when readiness is never reached.
Or skip the browser setup
If you need a hosted screenshot or PDF capture rather than maintaining Chromium orchestration, ScreenshotNeo provides a website screenshot API and MCP server. A single GET request can return PNG, JPEG, WebP, or PDF output, while its capture pipeline accepts cookie and consent banners before removing more than 60 known consent platforms, newsletter popups, and chat widgets. Each cleanup step can be disabled.
Only clean shots are billed. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.
For API parameters, PDF settings, readiness controls, and the complete option list, see the ScreenshotNeo documentation.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →One-call cURL example
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
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)
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}`);
ScreenshotNeo also supports full-page captures with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets and custom viewports, retina scale, PDF paper size/margins/landscape/page ranges, HTML/CSS-to-image, custom JavaScript and CSS, pre-capture clicks, hidden selectors, selector/delay/network-idle waits, request and resource blocking, custom headers/cookies/user agents/Authorization, timezone and geolocation, transparent backgrounds, resizing, chosen-TTL caching, signed links, asynchronous jobs with signed webhooks, bulk capture for 100 URLs per call, a usage API, an OpenAPI specification, and familiar parameter names for easier migration.
There is no browser setup to maintain: cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed; an MCP server lets AI agents take screenshots; 1,000 screenshots a month are free with no card, and paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.
Quick decision guide
| Requirement | Recommended approach |
|---|---|
| Exact application-controlled chart frame | Puppeteer plus an application-owned readiness signal |
| Screen styling rather than print styling | emulateMediaType('screen') |
| CSS backgrounds in the PDF | printBackground: true |
| Stylesheet-owned paper dimensions | preferCSSPageSize: true with @page |
| Accessible or searchable chart information | Canvas plus equivalent text and/or a data table |
| Managed capture without browser orchestration | ScreenshotNeo API or MCP server |
Frequently Asked Questions
Does waiting for network idle guarantee that a canvas is drawn?
No. Network-idle states describe loading activity, not whether your chart or renderer has completed its final visible draw. Wait for an application-owned readiness signal.
Should I use print or screen media for a PDF?
Use print media for a paper-oriented stylesheet. Call page.emulateMediaType('screen') when the PDF should follow the screen design.
Why is my canvas text not searchable in the PDF?
Canvas is a bitmap. Add equivalent HTML text or a data table when selection, search, or assistive-technology access matters.
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.

