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

There is no single React command that exports an app to PDF. Choose the method based on who should control the result: use window.print() for a person to preview and save, react-to-print to print one component, a browser-side PDF library for a small direct download, or Puppeteer to generate consistent PDFs automatically on a server.

For most production reports, build a dedicated printable React view and share its print styles between browser printing and automated generation. That keeps layout decisions in your app instead of relying on a screenshot of the whole interface.

Choose the right PDF export method

Method Best for Who controls saving? Main trade-off
Browser print with window.print() User-driven exports and pages that should remain selectable text The browser user chooses preview, destination, paper, and settings Not a silent or automatic download
react-to-print Printing one component rather than the whole app The browser user, through the normal print flow It does not itself save a PDF after opening print preview
Client-side DOM-to-canvas/PDF library Small, controlled documents that need a direct browser download Your client code initiates the download Rasterized content can impair text selection and complex pagination
Puppeteer Automated, repeatable or server-side PDF creation Your server or automation workflow Requires a Chromium runtime and careful handling of data and assets

React renders the interface; printing or PDF-generation tooling produces the PDF. Before choosing a tool, decide whether the export should be a selectable document or a visual capture, whether a user must approve it, and whether it must be generated in a repeatable server workflow.

Prepare a print-ready React view

A dashboard is rarely a good PDF without adjustment. Create a stable subtree for the document itself, and keep navigation, filters, buttons, and other export controls outside it. Use print CSS to define page geometry, hide screen-only elements, and manage breaks. The same styles can support the browser print dialog and Puppeteer, which uses print media by default.

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 a dedicated printable subtree

Keep the document content semantically structured: headings, paragraphs, tables, and links are generally more useful in a PDF than a single flattened image. For example:

function Report({ report }) {
  return (
    <main className="report-printable">
      <h1>{report.title}</h1>
      <p>Prepared for {report.customerName}</p>
      <table>
        <thead>
          <tr><th>Item</th><th>Amount</th></tr>
        </thead>
        <tbody>
          {report.items.map((item) => (
            <tr key={item.id}>
              <td>{item.name}</td>
              <td>{item.amount}</td>
            </tr>
          ))}
        </tbody>
      </table>
    </main>
  );
}

Add screen and print styles

Use ordinary styles for the on-screen view and a print media block for the exported page. The example sets a common page size, gives the paper printable margins, removes controls, and avoids splitting rows where possible. Confirm the exact output in the browsers and paper sizes your users need.

.report-printable {
  color: #111;
  background: #fff;
}

@media print {
  @page {
    size: A4;
    margin: 18mm;
  }

  .no-print,
  nav,
  .export-controls {
    display: none !important;
  }

  .report-printable {
    color: #111;
    background: #fff;
  }

  thead {
    display: table-header-group;
  }

  tr,
  img,
  figure {
    break-inside: avoid;
  }

  h1,
  h2,
  h3 {
    break-after: avoid;
  }
}

Print CSS is a set of instructions, not a guarantee that every browser will paginate identically. Check long tables, oversized images, headings at page bottoms, and content whose height changes after fonts or data load. A user may also override paper size, margins, headers, or background printing in the browser dialog.

Let the user print or save from the browser

For a user-controlled export, trigger the browser’s standard print flow. The user can review the page and choose a PDF destination where supported by their browser and operating system.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
function PrintButton() {
  return (
    <button className="no-print" onClick={() => window.print()}>
      Print or save as PDF
    </button>
  );
}

This is the simplest option when the person exporting should control the final destination and settings. It does not automatically create a file on your server, nor does it silently download a PDF. Make sure the printable content is already rendered before calling window.print(); for images and custom fonts, wait until they have loaded if missing assets would make the export incorrect.

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.

Print one component with react-to-print

When a page contains a dashboard but only one report should be printed, react-to-print can direct the print flow at a referenced component. Its current documented API uses contentRef; check the package documentation for the API appropriate to the version installed.

import { useRef } from "react";
import { useReactToPrint } from "react-to-print";

function ReportPage({ report }) {
  const contentRef = useRef(null);

  const printReport = useReactToPrint({
    contentRef,
    documentTitle: `report-${report.id}`,
  });

  return (
    <>
      <button className="no-print" onClick={printReport}>
        Print report
      </button>
      <section ref={contentRef} className="report-printable">
        <h1>{report.title}</h1>
        <p>{report.summary}</p>
      </section>
    </>
  );
}

The hook copies the target into a print iframe and invokes the ordinary browser print flow. documentTitle can supply a suggested document name, and the package also documents font options. The browser still owns preview and print settings; this package is not a silent PDF downloader. See the react-to-print documentation for version-specific options and behavior.

Because rendering takes place in an iframe, verify that the styles and fonts needed by the target component are available there. Test your actual supported devices: mobile browsers and embedded WebViews can have different print support from desktop browsers.

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

Generate a direct client-side PDF

A browser-side library can convert a bounded DOM region to a canvas or PDF and initiate a download without asking the user to navigate the whole page’s print dialog. This can suit a small invoice, certificate, or compact summary when a visual snapshot is acceptable.

There is no universally best library or configuration for every React layout, so the implementation should be selected and tested against the document you actually produce. Canvas-based capture commonly rasterizes content. That may make text less selectable, increase file size, or reduce accessibility compared with a document printed from semantic HTML. Long tables, page breaks, complex CSS, and content spanning multiple pages need particular attention. Do not assume that screen rendering will translate cleanly to paginated paper.

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.
  • Use this path when the document is bounded and you can validate its output at the target sizes.
  • Prefer browser printing or a browser-based server renderer when selectable text and CSS-driven pagination matter.
  • Test the generated file itself for clipped content, readable text, image quality, and page count before shipping.

Generate PDFs with Puppeteer on a server

For scheduled exports, batch jobs, or a repeatable server-side route, Puppeteer loads the rendered page in headless Chromium and writes a PDF. Puppeteer’s documentation says, “For printing PDFs use Page.pdf().” By default, page.pdf() waits for fonts and renders with print CSS media. Use page.emulateMediaType('screen') only if the output is intentionally meant to use screen styles instead. See the Puppeteer Page.pdf() documentation and emulateMediaType documentation.

Minimal Node.js example

Install Puppeteer in the server project, make the report route accessible to the browser instance, then run a script such as this. Replace the URL with your application’s export route.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const puppeteer = require("puppeteer");

(async () => {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();
    await page.goto("https://your-app.example/reports/123", {
      waitUntil: "networkidle2",
    });
    await page.pdf({
      path: "report.pdf",
      format: "A4",
      printBackground: true,
    });
  } finally {
    await browser.close();
  }
})();

The snippet uses a URL that must be reachable from the machine running Chromium. In a real export endpoint, use an authenticated session, a server-only route, or a short-lived signed export URL so the browser sees the intended report without exposing credentials in a public link.

Wait for application data, not just navigation

networkidle2 is a navigation heuristic, not proof that a React app has completed its data fetches or rendered the correct report. If the app fetches data after page load, expose a reliable ready signal in the export route and wait for it:

await page.goto(url, { waitUntil: "networkidle2" });
await page.waitForSelector("[data-pdf-ready='true']");
await page.pdf({ path: "report.pdf", format: "A4", printBackground: true });

Set that attribute only when the export’s data and layout are ready. If you use custom fonts or images, ensure they are loaded before the PDF call; missing or late assets can produce a PDF that differs from the page a user sees.

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

Choose print or screen styling deliberately

PDF generation uses print media by default, so the @media print rules in your app apply. To intentionally generate from screen styles, set the media type before printing:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.emulateMediaType("screen");
await page.pdf({ path: "report.pdf", format: "A4", printBackground: true });

Use printBackground: true when background colors or images are part of the design. For cases where preserving printed colors matters, CSS can use -webkit-print-color-adjust: exact; validate the result rather than assuming every style will be honored identically.

Use React server rendering only when it fits

renderToString converts a React tree to HTML, but it does not wait for data. If you need a React tree rendered outside the browser, fetch and resolve the required data first, then render the tree and pass the HTML to a browser or HTML-to-PDF renderer. For a full interactive app that already has an export route, loading that route in Puppeteer is often a more direct way to use the application’s existing rendering and styles. See the React renderToString documentation.

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

Or skip the browser setup

If you need a website screenshot rather than a paginated, selectable-text PDF of your React report, ScreenshotNeo provides a screenshot API and MCP server. It is not a replacement for a true report PDF when page breaks or document text matter. One GET request can return a screenshot or a PDF:

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://your-app.example/reports/123 
  -o report.pdf

For a PDF response, set the appropriate PDF options for your intended output; see the ScreenshotNeo API documentation. It can accept cookie or consent banners like a visitor and remove more than 60 known consent platforms, newsletter popups, and chat widgets before the shot; each step can be turned off. 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 server offers take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

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

Troubleshoot common PDF export problems

  • Print dialog opens, but no file downloads: That is expected for window.print() and react-to-print; the browser user must choose a PDF destination and save. Use an automated renderer if the workflow must save without user interaction.
  • The whole dashboard appears instead of the report: Print a dedicated subtree, add print rules to hide screen-only controls, or point react-to-print at the report’s ref.
  • Styles differ in the output: Puppeteer uses print media by default. Review @media print rules; switch to screen media only when that is the desired design. In an iframe-based print flow, confirm styles are available to the iframe.
  • Background colors or images are missing: In Puppeteer, set printBackground: true. Review browser print settings when the user is printing, and use -webkit-print-color-adjust: exact where color preservation is important.
  • Report data is missing or stale: Navigation completion does not necessarily mean asynchronous React data is ready. Wait for a meaningful application-ready selector before generating the PDF.
  • Fonts or images are absent: Ensure assets are reachable by the print iframe or headless browser, and delay capture until required assets have loaded.
  • Rows or headings split awkwardly: Use print break rules such as break-inside: avoid for suitable blocks, keep table headers repeatable, and test with realistic multi-page data. A rule cannot prevent every awkward split when content is taller than the remaining page.
  • Client-side PDF is blurry or hard to search: The library may have rasterized the DOM. Prefer a print-to-PDF or Chromium PDF route when selectable text and pagination are important.
  • Print works on desktop but not inside a mobile app: Browser and embedded WebView support differs. Test the actual target environment and offer a server-generated option if its print flow is unavailable.

Performance, reliability, and cost trade-offs

Browser printing shifts preview and final settings to the user and requires little PDF infrastructure from your app. Client-side capture avoids a server-side Chromium job but can use the user’s browser resources and requires visual QA. Puppeteer offers a repeatable generation path, but your service must run and maintain the browser environment, load the page and assets, and handle timeouts and failures. The supplied methods establish no universal runtime, capacity, or hosting cost figure; these depend on your document, infrastructure, and workload.

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.

For automated exports, keep the report route deterministic, wait for explicit readiness, close browser instances even when generation fails, and return a clear error rather than an incomplete file. For user-driven printing, provide a preview-friendly page and let the browser present destination settings. In either case, maintain the print stylesheet with the React view and test representative short and long reports.

Frequently Asked Questions

Can React export a PDF without another library?

Yes. Render a printable view and call the browser’s built-in window.print(); the user can then choose a PDF destination in the print flow.

Does react-to-print automatically download the PDF?

No. It opens the browser’s print flow for the referenced component; the browser user still chooses whether and where to save.

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

Should I use Puppeteer or a client-side PDF library?

Use Puppeteer for repeatable automated or server-side output. A client-side library can suit a small visual document that you have tested for text quality and pagination.

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.