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.

Use React only to trigger the request. Generate the PDF in a server-side Node.js process with Puppeteer, return the PDF bytes as an application/pdf response, and let the browser download those bytes as a Blob. Puppeteer is not a browser-side React library: launching Chromium belongs on your server or another browser runtime.

How the React-to-PDF flow works

  1. A user activates a semantic React <button>.
  2. The button’s onClick handler sends a request to your application endpoint.
  3. The endpoint launches (or reuses) Chromium, opens the report page, and calls page.pdf().
  4. The endpoint sends the resulting bytes with Content-Type: application/pdf and a download filename.
  5. React converts the response to a Blob, creates an object URL, clicks a temporary link, and eventually revokes that URL.

React documents event handlers as functions passed to onClick; write onClick={handleDownload}, not onClick={handleDownload()}, which would run during rendering. A real button also supplies keyboard and accessibility behavior.

Install Puppeteer in the server runtime

Install Puppeteer in the Node.js project that serves your API, not in a browser-only React bundle:

npm install puppeteer express

Puppeteer versions change; check the current PDF generation guide and API reference before pinning options. The examples below use the documented puppeteer.launch(), browser.newPage(), navigation, page.pdf(), and browser.close() sequence.

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
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Build the PDF endpoint

This Express example generates a report page and returns bytes directly. Replace reportUrl with a route your server can authenticate and render. If the report contains private data, validate the requested record on the server rather than accepting an arbitrary URL from the browser.

import express from 'express';
import puppeteer from 'puppeteer';

const app = express();

app.get('/api/report.pdf', async (req, res) => {
  let browser;
  try {
    browser = await puppeteer.launch();
    const page = await browser.newPage();

    await page.goto('http://localhost:3000/report', {
      waitUntil: 'networkidle0',
      timeout: 30_000
    });

    // PDF output uses print media by default. Keep this line only when
    // the report should use its screen styles instead.
    // await page.emulateMediaType('screen');

    const pdfBytes = await page.pdf({
      format: 'A4',
      printBackground: true,
      preferCSSPageSize: true,
      timeout: 30_000
    });

    res.status(200)
      .set({
        'Content-Type': 'application/pdf',
        'Content-Disposition': 'attachment; filename="report.pdf"',
        'Content-Length': String(pdfBytes.length)
      })
      .send(Buffer.from(pdfBytes));
  } catch (error) {
    console.error('PDF generation failed', error);
    if (!res.headersSent) {
      res.status(500).json({ error: 'PDF generation failed' });
    }
  } finally {
    if (browser) await browser.close();
  }
});

app.listen(3001, () => console.log('API listening on port 3001'));

page.pdf() returns a Promise<Uint8Array>. With no path, Puppeteer returns bytes without writing a file. The HTTP response shown here is application code built around that return value; Puppeteer’s guide does not prescribe an Express response handler.

Render the page you actually want to print

Navigate to a stable, server-reachable URL. In a production deployment, localhost may refer to a different container, so use an internal service name or render the report route in the same application. Wait for the data and fonts your page needs. networkidle0 can hang on pages with long-lived analytics or WebSocket connections; in that case wait for a report-specific selector instead.

await page.goto(reportUrl, { waitUntil: 'domcontentloaded' });
await page.waitForSelector('[data-report-ready]', { timeout: 30_000 });
await page.evaluate(() => document.fonts.ready);

Choose PDF options deliberately

Option Behavior When to use it
emulateMediaType('screen') Uses screen CSS instead of the default print media. When the PDF should match the on-screen design.
path Saves a file relative to the current working directory when the path is relative; without it, bytes are returned. Use for a server artifact; omit for an immediate HTTP download.
format Sets a paper preset such as A4. The documented default is Letter. Use a known paper size. format takes priority over width and height.
preferCSSPageSize Lets CSS @page dimensions take priority. Use when print layout is controlled by CSS.
printBackground Prints background graphics; default is false. Enable for colored panels, charts, and background images.
waitForFonts Waits for fonts by default. Keep the default unless you have a measured reason to change it; some circumstances require bringing the page to the foreground.
timeout PDF operation timeout defaults to 30,000 ms; 0 disables it. Raise it for unusually large documents, but fix slow pages rather than disabling protection blindly.

Printing can alter colors. Puppeteer points to -webkit-print-color-adjust when exact color reproduction is required:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .no-print { display: none !important; }
}
@page { size: A4; margin: 16mm; }

Connect the React button to the endpoint

import { useState } from 'react';

export default function DownloadPdfButton() {
  const [busy, setBusy] = useState(false);
  const [error, setError] = useState('');

  async function handleDownload() {
    setBusy(true);
    setError('');
    try {
      const response = await fetch('/api/report.pdf', {
        headers: { Accept: 'application/pdf' }
      });
      if (!response.ok) {
        const message = await response.text();
        throw new Error(message || `Request failed (${response.status})`);
      }
      const blob = await response.blob();
      const objectUrl = URL.createObjectURL(blob);
      const link = document.createElement('a');
      link.href = objectUrl;
      link.download = 'report.pdf';
      document.body.appendChild(link);
      link.click();
      link.remove();

      // Do not revoke before the browser has had a chance to start the
      // download. Adjust this cleanup timing for your supported browsers.
      setTimeout(() => URL.revokeObjectURL(objectUrl), 1000);
    } catch (err) {
      setError(err instanceof Error ? err.message : 'PDF download failed');
    } finally {
      setBusy(false);
    }
  }

  return (
    <div>
      <button type="button" onClick={handleDownload} disabled={busy}>
        {busy ? 'Preparing PDF…' : 'Download PDF'}
      </button>
      {error && <p role="alert">{error}</p>}
    </div>
  );
}

The anchor download attribute requests download behavior for same-origin, blob:, and data: URLs. Each createObjectURL() call creates a distinct URL that should eventually be revoked, but revoking it while the resource remains accessible can cancel the download in some browsers. Test your supported browser set rather than assuming that immediate revocation is universally safe.

Server-file versus returned bytes

Return bytes for an immediate download

This is the endpoint above: the browser receives one response and owns the download. It avoids exposing a server filesystem path and does not require cleanup of a retained file, but the request remains open while Chromium renders and transfers the PDF.

Save a server artifact

await page.pdf({ path: '/srv/reports/report-123.pdf', format: 'A4' });

A saved file is useful when another job, object-storage upload, or later download needs the artifact. Secure the directory, generate non-guessable names, enforce retention, and return a controlled download URL. A path alone does not download anything to the user’s computer.

Use a remote browser

A hosted browser can reduce the work of operating Chromium locally. Browserless documents a Puppeteer download API, but it adds an external dependency; the cited capability does not establish pricing or comparative reliability.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Authentication, assets, and production reliability

  • Authentication: pass server-held credentials or cookies to the page; never expose privileged tokens in the React bundle. Use page.setCookie() or request headers where appropriate.
  • Images and fonts: make assets reachable from the browser process, use absolute URLs, and wait for readiness. Broken relative URLs are common when the API runs in another container.
  • Concurrency: close pages and browsers in finally blocks. For higher volume, a controlled browser pool can avoid launch overhead, but cap concurrent pages to protect memory.
  • Navigation safety: validate destinations and block arbitrary user-supplied URLs to prevent server-side request forgery.
  • Large reports: stream or store them when response size and request duration exceed your proxy limits. Add request authentication, rate limits, and cancellation handling.
  • Observability: log a request ID, navigation duration, PDF duration, page URL, and error class without logging private report contents.

Troubleshooting common failures

“Executable doesn’t exist” or Chromium will not launch

Install the Puppeteer package in the server deployment and ensure its browser download is included. If your platform supplies its own Chromium, configure the executable path explicitly and verify required OS libraries. Do not attempt to launch it from React client code.

The endpoint returns HTML instead of a PDF

Inspect the status and Content-Type. A login redirect, framework error page, or proxy timeout often means the server never reached page.pdf(). Return JSON errors only before headers are sent and check the server logs.

The PDF is blank or missing data

Wait for a deterministic readiness selector or data promise rather than relying only on a short delay. Confirm that the API’s Chromium process can reach the data service and that authentication cookies are present.

Colors or backgrounds are missing

Set printBackground: true, inspect print media CSS, and add print color adjustment when exact colors matter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

The layout uses the wrong paper size

Remove conflicting width/height values when using format, or set preferCSSPageSize: true when your @page rule should win.

The request times out

Find whether navigation, fonts, data, or PDF rendering is slow. Replace an unsuitable networkidle0 wait, wait for a specific selector, optimize assets, and raise the documented 30-second PDF timeout only when necessary.

The click does nothing

Confirm that the handler is passed, not called during render, that the button is not disabled, and that the browser console and Network panel show the request. A failed response should be surfaced through the component’s error state.

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 is a website screenshot API and MCP server when you need a rendered page or PDF without operating Puppeteer yourself. It accepts consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP tools—take_screenshot, get_page_info, and capture_pdf—work with Claude, Cursor, and other MCP clients.

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

For a PDF or screenshot request, see the ScreenshotNeo documentation. A simple image call looks like this:

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

There is a free plan with 1,000 shots per month and no card; paid plans start at $5 for 3,000 shots. Every feature is on every plan. Create a free ScreenshotNeo account.

Security and cost checklist

  • Keep the API endpoint authenticated if reports contain private information.
  • Do not accept unrestricted URLs or JavaScript from users.
  • Set navigation and PDF timeouts and enforce a maximum report size.
  • Close browser resources even when generation fails.
  • Decide whether launch-per-request overhead, a browser pool, stored files, or a hosted browser best fits your traffic.
  • Measure your own render time and memory use; the official documentation does not provide a universal performance benchmark.

Frequently Asked Questions

Can Puppeteer generate a PDF directly in a React component?

No. Keep Puppeteer in a server-side Node.js runtime or remote browser service and call it through an authenticated application endpoint.

Should I use page.pdf({ path }) for a download?

Use path when you need a server-side artifact. For an immediate browser download, omit path, return the PDF bytes, and create a Blob and download link in React.

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

Why does my PDF look different from the webpage?

Puppeteer uses print media by default. Use emulateMediaType(‘screen’) for screen CSS, and enable printBackground when background graphics are required.

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.