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

Wait for the Leaflet layer, not merely the page. Puppeteer’s networkidle2 navigation condition and its default font wait address different parts of rendering; neither confirms that the map’s visible tiles for the final center and zoom have loaded. Register Leaflet load and tileerror listeners before changing the view, verify isLoading() is false, then call page.pdf(). If the PDF is still truncated, inspect print CSS, fixed heights, overflow, page breaks, backgrounds and page ranges.

Why a PDF can finish before the map does

A successful page.goto() means navigation reached its chosen readiness condition. It does not mean application code has finished a pan, zoom, layer replacement or asynchronous tile draw. Puppeteer’s PDF guide demonstrates waitUntil: 'networkidle2' followed by page.pdf(), and states that PDF generation waits for fonts by default. Those guarantees are separate from Leaflet’s tile lifecycle.

Leaflet’s GridLayer emits loading, tileloadstart, tileload, tileerror and load. Its load event means all visible tiles for that grid layer have loaded; isLoading() reports whether any tile remains unfinished. Use the event for the exact final view rather than guessing with a sleep.

A reliable Puppeteer sequence

  1. Record the environment. Log Puppeteer, Chromium, Leaflet, operating-system or container, viewport and tile-provider configuration. Reproduce with the same values.
  2. Navigate separately from application readiness. Use networkidle2 if it helps initial navigation, but expose a page-level readiness promise for the map.
  3. Attach listeners before the final map action. A listener installed after a pan or zoom can miss an event that already fired.
  4. Wait for every relevant layer. Repeat the wait after a later pan, zoom, resize or layer replacement that changes visible tiles.
  5. Generate the PDF only after readiness resolves. Keep a bounded timeout and include diagnostics in the timeout error.

Runnable example

const browser = await puppeteer.launch({headless: true});
const page = await browser.newPage();
await page.setViewport({ width: 1440, height: 900, deviceScaleFactor: 1 });

await page.goto('https://example.com/map', {
  waitUntil: 'networkidle2',
  timeout: 90000
});

// Install this before the code that sets the final center/zoom.
await page.evaluate(async () => {
  const layer = window.myTileLayer; // expose the exact Leaflet layer on the page
  if (!layer) throw new Error('myTileLayer is not available');

  // The layer may already be idle, so do not wait for an event that has fired.
  if (!layer.isLoading()) return;

  await new Promise((resolve, reject) => {
    let timer;
    const errors = [];
    const cleanup = () => {
      clearTimeout(timer);
      layer.off('load', onLoad);
      layer.off('tileerror', onError);
    };
    const onLoad = () => {
      if (!layer.isLoading()) { cleanup(); resolve(); }
    };
    const onError = event => {
      errors.push(event && event.coords ? event.coords : event);
      console.error('Leaflet tile error', event);
      // Decide in your application whether an error is fatal.
    };
    timer = setTimeout(() => {
      cleanup();
      reject(new Error(`Leaflet tiles timed out; still loading=${layer.isLoading()}, errors=${errors.length}`));
    }, 30000);
    layer.on('load', onLoad);
    layer.on('tileerror', onError);
  });
});

await page.pdf({
  path: 'map.pdf',
  format: 'A4',
  printBackground: true
});
await browser.close();

The example assumes your page exposes window.myTileLayer. Adapt it to the real layer and to all layers that must appear in the document. Install the listeners before initiating the final view change; in production, wrap the center/zoom update and the wait in one page-level operation so the readiness promise describes that specific view.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Brother DCP-L2640DW Wireless Compact Monochrome Multi-Function Printer, Copy, Scan, Duplex, Mobile Printing
  • BEST FOR SMALL BUSINESSES – Engineered for extraordinary productivity, the Brother DCP-L2640DW Monochrome (Black & White) 3-in-1 combines laser printer, scanner, copier in one compact footprint and delivers high-quality black & white prints
  • FAST PRINTER WITH EFFICIENT SCANNING – Produces documents quickly with print speeds up to 36 ppm(2) and scan speeds up to 23.6/7.9 ipm(3) (black/color). A 50-page auto document feeder(4) allows for convenient, time saving multi-page scanning and copying
  • FLEXIBLE CONNECTION OPTIONS – Easily navigate the changing demands of your business with secure multi-device connectivity via built-in dual-band wireless (2.4GHz / 5GHz) and Ethernet. Or connect locally to a single computer via USB interface
  • BROTHER MOBILE CONNECT APP – Print, scan, and manage your wireless printer anytime, from almost anywhere from your mobile device. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(5)
  • CHOOSE BROTHER GENUINE TONER – When it’s time to replace your toner, be sure to choose Brother Genuine TN830 or TN830XL replacement toner. And with Refresh EZ Print Subscription Service, you’ll never worry about running out of toner again and you’ll enjoy savings of up to 50%(6) on Brother Genuine Toner. Get started with Refresh today with a Free Trial(1)

Waiting for a final pan or zoom

For an already-loaded map, call isLoading() first. For a new view, register the listeners, perform map.setView(...) or the equivalent action, then await load. A previous view’s load event is not evidence that the new visible tile set is complete.

Custom GridLayer implementations

If you extend Leaflet, your asynchronous createTile implementation must invoke Leaflet’s done callback when drawing or loading completes, including failure. Without that callback, Leaflet cannot know that work finished and its loading state can remain incorrect.

Print settings that make a complete map look incomplete

Print media versus screen media

page.pdf() uses print CSS media by default. That can intentionally hide controls, change dimensions or alter pagination. If the required output should match screen styles, call:

Rank #2
Brother HL-L2405W Wireless Compact Monochrome Laser Printer with Mobile Printing, Black & White Output | Includes Refresh Subscription Trial(1), Works with Alexa
  • BEST FOR HOMES & HOME OFFICES – Engineered for consistent, premium print quality, the Brother HL-L2405W Monochrome (Black & White) Laser Printer delivers sharp, crisp prints at an affordable price. Prints one-sided documents at speeds up to 30ppm(2)
  • COMPACT, CONNECTED PRINTER – Flexible connection options make this an ideal printer for home use and at-home offices. Securely connect to multiple devices with built-in dual-band wireless (2.4GHz/5GHz) or locally to a single computer via USB interface
  • BROTHER MOBILE CONNECT APP – Manage your printer remotely and print from your mobile device anytime, from almost anywhere. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(3)
  • VERSATILE PAPER HANDLING – Enjoy seamless, reliable everyday printing with the 250-sheet paper tray(4) and a manual feed slot that enables printing on envelopes and specialty pape
  • BROTHER IS AT YOUR SIDE – Backed by Brother with a 1-year limited warranty and free online, call, or live chat support for the life of your printer
await page.emulateMediaType('screen');

Do this deliberately; screen media is not automatically more correct. Inspect @media print rules, @page size, fixed heights, overflow, hidden elements and page-break rules.

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

Backgrounds and colors

PDF backgrounds are disabled by default. Enable them when tile or map styling depends on CSS backgrounds:

await page.pdf({ printBackground: true });

Printed colors may be adjusted. If exact CSS colors matter, use -webkit-print-color-adjust: exact in the relevant styles, while understanding that it affects the print rendering contract.

Rank #3
Canon imageCLASS LBP6030w - Monochrome Single-Function Wireless Compact Wireless Laser Printer, 1 Year Limited Warranty, 19 PPM, White - Print Only
  • FAST PRINT SPEEDS: Print up to 19 pages per minute.
  • COMPACT DESIGN: Space-saving, compact design fits anywhere in your home, school or small office.
  • WIRELESS CONNECTIVITY: Print from almost anywhere in your workspace using your compatible mobile device.
  • PAPER CAPACITY: Up to 150 sheets.
  • SUSTAINABILITY: Uses less than 2 watts in Energy Saver mode.

Pages and ranges

A document that stops after page one can be a CSS layout problem rather than a tile race. Confirm that pageRanges is empty or unset when all pages are required. Check fixed-height map containers, ancestor overflow, accidental clipping, page-break declarations and content that is hidden only in print media.

Diagnosing blank, partial or hanging output

Blank map area

  • Inspect layer.isLoading() and capture console messages.
  • Listen for tileerror; an HTTP failure, blocked request or provider limit may leave missing tiles.
  • Verify the map container has a non-zero size before calling map.invalidateSize() and beginning the final view.
  • Check that the tile URL, custom headers, cookies and user agent work in the Chromium environment.

Intermittent missing tiles

Do not replace readiness with a fixed delay. A delay can hide a race on one machine and fail on a slower container. Use a timeout to prevent an endless job, log the number and coordinates of tile errors, and choose whether any error is fatal or whether a partial map is acceptable.

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

One-page or truncated PDF

A 2018 Puppeteer issue reported “single page, content lost” with Puppeteer 1.8.0 on Windows 10. It is a historical symptom, not evidence of a current universal defect. Reproduce on the deployed versions, then inspect print CSS, container heights, overflow, page breaks and pageRanges before changing browser versions.

Rank #4
Brother HL-L2460DW Wireless Compact Monochrome Laser Printer with Duplex, Mobile Printing, Black & White Output | Includes Refresh Subscription Trial(1), Works with Alexa
  • BEST FOR HOME OFFICES & SMALL TEAMS – Engineered for consistent, premium print quality, the Brother HL-L2460DW Monochrome (Black & White) Laser Printer produces documents that are clear, crisp, and easy to review and share, all at an affordable price
  • COMPACT, CONNECTED, EXCEPTIONALLY EFFICIENT– Connect with built-in dual-band wireless (2.4GHz/5GHz), Ethernet, or to a single computer via USB interface. Prints at speeds up to 36ppm(2), plus automatic duplex printing saves time and reduces paper waste
  • BROTHER MOBILE CONNECT APP – Manage your wireless printer remotely and print from your mobile device anytime, from almost anywhere. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(3)
  • VERSATILE PAPER HANDLING – Tackle high-volume black & white printing with the 250-sheet capacity paper tray.(4) The manual feed slot enables printing on envelopes and specialty paper
  • BROTHER IS AT YOUR SIDE – Backed by Brother with a 1-year limited warranty and free online, call, or live chat support for the life of your printer

PDF generation hangs around fonts

A 2021 user issue described a font-related hang with Puppeteer 7.0.1 in specific macOS and Ubuntu/Heroku environments. Current Puppeteer options document font waiting, but that report does not establish a general cause. Log the deployed version, font requests and the exact timeout; test whether the page completes with the intended fonts available.

Handling tile failures safely

Leaflet can emit tileerror and later still emit load. Treat those as separate signals. If every tile is required, reject on an error and report the URL or coordinates. If a partial map is useful, retain the error list in job metadata and mark the PDF as partial rather than silently calling it complete. For multiple overlays, wait for each required layer independently; one layer’s load says nothing about another layer.

Performance, reliability and cost considerations

  • Bound work: use navigation and tile timeouts so a provider outage cannot consume a worker forever.
  • Control the viewport: larger dimensions and retina scale request more tiles and increase PDF memory use.
  • Reuse Chromium carefully: browser reuse reduces startup overhead, but reset cookies, local storage and page state between jobs.
  • Use caching consciously: a cached tile can complete quickly, while a cold request exposes real provider latency. Test both if reliability matters.
  • Separate readiness logs: record navigation completion, final view change, first tile event, tile load, tile errors and PDF completion.
  • Do not claim a failure rate: no attributable prevalence statistic establishes how often incomplete PDFs or missing Leaflet tiles occur.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server when you need a rendered page image or PDF without maintaining Puppeteer orchestration. It accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, 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.

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

One GET request returns PNG, JPEG, WebP or PDF. See the ScreenshotNeo documentation for all options, including full-page lazy-image loading, CSS-selector element capture, dark mode, device presets, retina scale, PDF paper and page ranges, custom CSS and JavaScript, click and wait actions, request blocking, headers, cookies, user agent, authorization, timezone, geolocation, transparent backgrounds, resizing, TTL caching, signed links, asynchronous webhooks, bulk capture and usage reporting.

Best Value
HP LaserJet M110w | Monochrome | Laser Printer
  • FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for small teams printing professional-quality black & white documents and reports. Perfect for 1-3 people
  • WORLD'S SMALLEST LASER IN ITS CLASS – Precision laser printing that fits anywhere
  • FAST PRINT SPEEDS – Up to 21 black-and-white pages per minute single-sided
  • WIRELESS WITH SELF-RESET – Helps you stay connected
  • PRINT FROM ANY DEVICE – Wireless printing from any mobile device, PC or tablet. Works with Microsoft, Mac, AirPrint, Android, Chromebook and more

cURL

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}`);

The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing provides two months free, and every feature is on every plan. Create a free ScreenshotNeo account to try it.

Frequently Asked Questions

Should I wait for `networkidle0` instead of `networkidle2`?

Neither navigation condition is a Leaflet readiness signal. Keep navigation waiting separate and wait for the final layer’s `load` event plus `isLoading() === false`.

Can a tile error be followed by a successful `load` event?

Yes. Record `tileerror` independently and decide whether your application should reject the PDF or label it partial.

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.

Why does my map differ in the PDF even though all tiles loaded?

PDF generation uses print media by default. Compare `@media print`, page dimensions, overflow, backgrounds and color adjustment before switching to screen media.

What does a custom Leaflet layer need to do?

Its asynchronous `createTile` function must call Leaflet’s `done` callback when the tile finishes drawing or fails.

Quick Recap

Bestseller No. 3
Canon imageCLASS LBP6030w - Monochrome Single-Function Wireless Compact Wireless Laser Printer, 1 Year Limited Warranty, 19 PPM, White - Print Only
Canon imageCLASS LBP6030w - Monochrome Single-Function Wireless Compact Wireless Laser Printer, 1 Year Limited Warranty, 19 PPM, White - Print Only
FAST PRINT SPEEDS: Print up to 19 pages per minute.; PAPER CAPACITY: Up to 150 sheets.; SUSTAINABILITY: Uses less than 2 watts in Energy Saver mode.
$134.99
Bestseller No. 5
HP LaserJet M110w | Monochrome | Laser Printer
HP LaserJet M110w | Monochrome | Laser Printer
WORLD'S SMALLEST LASER IN ITS CLASS – Precision laser printing that fits anywhere; FAST PRINT SPEEDS – Up to 21 black-and-white pages per minute single-sided

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.