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

For a person to save a React page as a PDF, make the page print-friendly and call window.print(); the browser opens its print dialog, where the person chooses a PDF destination. To generate and deliver a PDF automatically, render the page in a headless browser such as Puppeteer and call page.pdf(). Use react-to-print when the person should print just one React component rather than the whole document.

Choose the right PDF workflow

The key choice is who controls the export. Browser printing leaves the final save action to the person using the page. Server-side rendering lets your application generate and deliver a PDF without relying on someone to use print preview.

Question Browser print Server-side PDF
Who starts it? The user clicks a button that calls window.print(), or uses a React print helper. Your application code renders a route or template and invokes a browser PDF API.
Who saves the file? The user chooses a destination in the browser’s print interface. Your application receives the generated PDF and decides how to return or store it.
What styling applies? The browser applies print styles such as @media print. Puppeteer uses print media by default; it can emulate screen media before PDF creation.
Can it target one component? react-to-print can print a referenced component. Render the desired content at a dedicated route or template.
What must you operate? The end user’s browser and print workflow. A headless browser in your infrastructure, or a hosted rendering service.

These are differences in documented behavior, not a performance or fidelity ranking. Choose based on whether the export must be user-driven, what styling you need, and whether you can operate browser automation.

Make a React page print-ready

Start with semantic content that remains readable without interactive controls. Add print styles to remove navigation and buttons, control widths and typography, and avoid awkward page breaks where possible. The browser’s print interface still determines the available save destinations and controls.

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.

Use print CSS and page settings

/* styles.css */
@media print {
  .site-header,
  .site-nav,
  .no-print,
  button {
    display: none !important;
  }

  body {
    color: #000;
    background: #fff;
    font-size: 12pt;
  }

  main {
    width: 100%;
    margin: 0;
  }

  .keep-together {
    break-inside: avoid;
  }
}

@page {
  size: A4 portrait;
  margin: 15mm;
}

Change size to the paper size and orientation your users need, and adjust margins for the content. Print CSS can hide application chrome while retaining content that should appear on paper. Test long tables, images, headings, and repeated sections in the browser print preview; the CSS is a layout instruction, not a guarantee that every browser will paginate identically.

Open the print dialog from React

import React from 'react';
import './styles.css';

export default function ReportPage() {
  function printPage() {
    window.print();
  }

  return (
    <main>
      <header className="site-header no-print">My application</header>
      <h1>Quarterly report</h1>
      <p>This is the content that should appear in the PDF.</p>
      <button className="no-print" onClick={printPage}>
        Print or save as PDF
      </button>
    </main>
  );
}

window.print() opens the print dialog for the current document; it does not silently save a PDF or return PDF bytes to your JavaScript. Let the user initiate it from a clear action, and explain that they can select a PDF destination in the print interface.

Print one component with react-to-print

When a page contains several sections but the export should include only one, react-to-print provides a component-oriented browser print flow. Its documentation uses a ref and useReactToPrint. The resulting workflow still uses print preview: the package documentation says it does not directly download a PDF through the native route.

import React, { useRef } from 'react';
import { useReactToPrint } from 'react-to-print';

function Invoice() {
  const invoiceRef = useRef(null);
  const printInvoice = useReactToPrint({
    contentRef: invoiceRef,
    documentTitle: 'invoice'
  });

  return (
    <>
      <button onClick={printInvoice}>Print invoice</button>
      <article ref={invoiceRef}>
        <h1>Invoice</h1>
        <p>Invoice content goes here.</p>
      </article>
    </>
  );
}

export default Invoice;

Use the API shape documented for the version actually installed in your project; package APIs can change. The print styles still matter for the selected component. The library also documents callbacks and a custom print handler, which can hand content to a separate PDF generator if you need a direct-download flow. The generator then has its own setup and rendering behavior.

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.

Generate a PDF automatically with Puppeteer

For an application-managed file, run a headless browser in a server-side environment, navigate to the React route, and call page.pdf(). The route must render the content you intend to export and be reachable by the rendering process. Unlike the user-driven print flow, this lets your code handle the resulting PDF buffer.

Install and create a PDF route

Install Puppeteer using the package manager and deployment instructions appropriate to your environment. The example below assumes a Node.js server and an application route that returns the finished PDF. It uses a public URL for clarity; private pages need an authentication strategy that the browser process can use.

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

const app = express();

app.get('/reports/quarterly.pdf', async (req, res) => {
  let browser;

  try {
    browser = await puppeteer.launch({ headless: true });
    const page = await browser.newPage();

    await page.goto('https://example.com/reports/quarterly', {
      waitUntil: 'networkidle0'
    });

    const pdf = await page.pdf({
      format: 'A4',
      printBackground: true,
      margin: {
        top: '15mm',
        right: '15mm',
        bottom: '15mm',
        left: '15mm'
      }
    });

    res.setHeader('Content-Type', 'application/pdf');
    res.setHeader('Content-Disposition', 'attachment; filename="quarterly-report.pdf"');
    res.send(pdf);
  } catch (error) {
    console.error('PDF generation failed:', error);
    res.status(500).send('Could not generate the PDF.');
  } finally {
    if (browser) await browser.close();
  }
});

app.listen(3000);

Replace the example address with the route your server should render. Use a PDF response header and a filename suited to your download flow. The exact deployment setup for Chromium depends on the host environment; ensure the browser can launch there and close it after work so resources are released.

Control print media, colors, and fonts

page.pdf() renders using print CSS media by default. If you specifically want the screen stylesheet instead, emulate screen media before creating the PDF:

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.
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.
await page.emulateMediaType('screen');
const pdf = await page.pdf({ printBackground: true });

By default, Puppeteer modifies colors for printing. Its documentation points to -webkit-print-color-adjust when exact color rendering is required. For example, apply it selectively to elements where preserving background colors matters:

@media print {
  .brand-color {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

Puppeteer’s PDF method waits for fonts to load by default. If the page depends on additional asynchronous data, make sure that data is ready before calling page.pdf(); navigation completion alone does not necessarily mean your application-specific content is ready.

Consider Playwright if it is already in your stack

Playwright’s Page API also exposes PDF-related options, including an output path and scale controls. The precise API is version-sensitive, so consult the official documentation for the version deployed in your application before copying options. The documented material here does not establish a speed, cost, or output-quality advantage over Puppeteer.

Or skip the browser setup

If you need a screenshot or PDF of a page by URL rather than a custom browser-rendering service, ScreenshotNeo offers a website screenshot API. It can return PNG, JPEG, WebP, or PDF from one GET request. This is useful for a public route that is already rendered, but it is not a replacement for building print-specific React styles or for a workflow that requires custom server-side application logic.

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

For example, this cURL request captures the Stripe homepage as a WebP image:

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 API documentation for request options, including PDF capture and response details. Its documented reasons to consider it are concrete: it accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; only clean shots are billed, while bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing; and its MCP server gives AI agents tools for screenshots, page information, and PDF capture. The free plan includes 1,000 shots a month without a card; paid plans start at $5 for 3,000 shots. Sign up for the free plan to try 1,000 screenshots a month with no card.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

The PDF contains navigation or buttons

Add print rules that hide interactive elements, using a dedicated class such as no-print. Check that the stylesheet containing @media print is loaded by the route you are printing.

The component print helper prints too much or too little

Check that the ref is attached to the exact component intended for printing and that the helper is configured with the API supported by your installed package version. Use browser print preview to inspect the selected content before changing styles.

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

The generated PDF has unexpected styling

Check whether print media is active. Puppeteer uses print media by default; call page.emulateMediaType('screen') before page.pdf() only if screen styles are intended. For backgrounds or colors, inspect your print CSS and Puppeteer’s print color behavior.

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.

The page is missing data or fonts

Make sure the route can finish loading its data before PDF generation. Puppeteer waits for fonts by default, but application-specific asynchronous rendering may need an explicit readiness condition in your own page flow.

The server returns an error instead of a PDF

Check the server log for browser launch or navigation errors, verify the target route is reachable from the server environment, and ensure the browser is closed in a finally block. Deployment hosts differ in their Chromium requirements, so follow the host’s supported browser setup.

Reliability, performance, and cost considerations

The print-dialog approach delegates rendering to the end user’s browser and avoids operating server-side browser automation, but the application cannot silently save the output through window.print(). The Puppeteer route gives your application control over PDF delivery, at the cost of running a browser and handling its deployment and lifecycle. The cited API documentation establishes these mechanisms, not comparative measurements of speed, cost, accessibility, or fidelity.

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

For repeated or high-volume generation, account for browser process lifecycle and the readiness of the page being rendered. Test representative content and deployment conditions rather than assuming a result observed in one browser or host applies everywhere. Check current Puppeteer, Playwright, and react-to-print documentation against the installed versions before relying on a specific option.

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.