I have found below in their site documentation

import { PDFDownloadLink, Document, Page } from '@react-pdf/renderer'

const MyDoc = () => (
  <Document>
    <Page>
      // My document data
    </Page>
  </Document>
)

const App = () => (
  <div>
    <PDFDownloadLink document={<MyDoc />} fileName="somename.pdf">
      {({ blob, url, loading, error }) => (loading ? 'Loading document...' : 'Download now!')}
    </PDFDownloadLink>
  </div>
)
Answer from gujaru on Stack Overflow
🌐
React-pdf
react-pdf.org
React-pdf
React renderer for creating PDF files on the browser and server
Styling
React renderer for creating PDF files on the browser and server
Advanced
There are some cases in which you may need to generate a document without showing it on screen. For those scenarios, react-pdf provides three different solutions: Is it possible that what you need is just a "Download" button.
Components
Iframe PDF viewer for client-side generated documents. Other props are passed through to the iframe. Anchor tag to enable generate and download PDF documents on the fly.
Rendering process
React renderer for creating PDF files on the browser and server
🌐
npm
npmjs.com › package › react-pdf
react-pdf - npm
Install by executing npm install react-pdf or yarn add react-pdf.
      » npm install react-pdf
    
Published   Oct 09, 2025
Version   10.2.0
Author   Wojciech Maj
🌐
GitHub
github.com › diegomura › react-pdf
GitHub - diegomura/react-pdf: 📄 Create PDF files using React
This package is used to create PDFs using React.
Starred by 16.2K users
Forked by 1.3K users
Languages   TypeScript 83.1% | JavaScript 16.8%
🌐
npm
npmjs.com › package › react-to-pdf
react-to-pdf - npm
import { usePDF } from 'react-to-pdf'; const Component = () => { const { toPDF, targetRef } = usePDF({filename: 'page.pdf'}); return ( <div> <button onClick={() => toPDF()}>Download PDF</button> <div ref={targetRef}> Content to be generated to PDF </div> </div> ) } Stackblitz demo ·
      » npm install react-to-pdf
    
Published   Nov 25, 2025
Version   2.0.3
Author   Marcos Andrei Ivanechtchuk
🌐
Syncfusion
ej2.syncfusion.com › react › documentation › pdfviewer › download
Download in React Pdfviewer component | Syncfusion
import * as ReactDOM from 'react-dom'; import * as React from 'react'; import './index.css'; import { PdfViewerComponent, Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, Print, TextSelection, Annotation, TextSearch, Inject } from '@syncfusion/ej2-react-pdfviewer'; let pdfviewer; function App() { function downloadClicked() { var viewer = document.getElementById('container').ej2_instances[0]; viewer.download(); } return (<div> <div className='control-section'> {/* Render the PDF Viewer */} <button onClick={downloadClicked}>Download</button> <PdfViewerComponent re
🌐
Wojtekmaj
projects.wojtekmaj.pl › react-pdf
React-PDF
Easily display PDFs in your React app.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › how-to-download-pdf-file-in-reactjs
How To Download PDF file in ReactJS? - GeeksforGeeks
The fetch() method allows you to fetch PDF files from a server or URL and download them dynamically. Unlike the anchor tag approach, this method fetches the file asynchronously and provides more flexibility, especially if the file is hosted ...
Published   July 23, 2025
🌐
CodeSandbox
codesandbox.io › examples › package › react-pdf
react-pdf examples - CodeSandbox
AboutDisplay PDFs in your React app as easily as if they were images.2,318,614Weekly Downloads · Latest version10.2.0 · LicenseMIT · External Links · github.com/wojtekmaj/react-pdf ·
Top answer
1 of 3
1

Download File in React.js To download a file with React.js, we can add the download attribute to an anchor element.

For instance, we can write:

import React from "react";

export default function App() {
  return (
    <div>
      <a     href="https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
        download
      >
        Click to download
      </a>
    </div>
  );
}

We just add the download prop to do the download.

If we don’t want to use an anchor element, we can also use the file-saver package to download our file.

To install it, we run:

npm i file-saver

Then we can call the saveAs function from the package by writing:

import React from "react";
import { saveAs } from "file-saver";

export default function App() {
  const saveFile = () => { saveAs("https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
      "example.pdf"
    );
  };
  return (
    <div>
      <button onClick={saveFile}>download</button>
    </div>
  );
}

The first argument is the URL to download and the 2nd argument is the file name of the downloaded file.

2 of 3
1

I just had the same issue myself, literally a few minutes ago, and I found two solutions to this: Download the file or open it in a new tab and allow the user to decide if they want to download it or not.

A quick note: the file I have is located in the /public/data folder of my project, since I treat it as a static asset.

  1. Download the file:
<a
   href={process.env.PUBLIC_URL + 'data/random_file.pdf'}
   download='random_file.pdf'
>
   <button>Download Random File</button>
</a>
  1. Open the file in a new tab for the user to view or download.
<a
   href={process.env.PUBLIC_URL + 'data/random_file.pdf'}
   target='_blank'
   rel='noopener noreferrer'
>
   <button>Open Random File</button>
</a>

Also, it might be a bit late to mention but I am extremely new to web development and React so please take this info with a grain of salt. And I hope this solution works for you too, or at least points you in the right direction.

🌐
GitHub
github.com › wojtekmaj › react-pdf
GitHub - wojtekmaj/react-pdf: Display PDFs in your React app as easily as if they were images.
Install by executing npm install react-pdf or yarn add react-pdf.
Starred by 10.7K users
Forked by 981 users
Languages   TypeScript 94.3% | CSS 5.6% | HTML 0.1%
🌐
DEV Community
dev.to › abhay1kumar › step-by-step-guide-to-generate-and-download-pdfs-with-react-pdf-filesaver-and-jszip-1l53
Step-by-Step Guide to Generate and Download PDFs with React-PDF, FileSaver, and JSZip - DEV Community
September 12, 2024 - In this tutorial, we’ve covered how to generate and download multiple PDFs in a React application. By using @react-pdf/renderer, JSZip, and file-saver, you can create a seamless experience for generating and downloading documents.
🌐
JavaScript in Plain English
javascript.plainenglish.io › download-pdf-from-api-in-reactjs-using-axios-and-blobs-699be8a27ca7
Download PDF from API in React (Using Axios and blobs) | by Subhanu | JavaScript in Plain English
December 11, 2024 - Setting up the project is the first step towards downloading files from an API in ReactJS using axios and blobs. Let's follow along to get started: Create a new ReactJS project or navigate to your existing project directory. Open a terminal and run the following command to install axios: ... 4. Next, create a basic file structure for your project. We can organize your files in a way that suits your needs, but here’s a simple example: src/ ├── components/ │ └── PDFDownloader.js └── App.js
🌐
Rip Tutorial
riptutorial.com › Download › react.pdf pdf
React #reactjs
Stateless React Components in Typescript · 123 · Installation and Setup · 123 · Stateless and property-less Components · 124 · Credits · 126 · About · You can share this PDF with anyone you feel could benefit from it, downloaded the latest version ·
🌐
Stackademic
stackademic.com › blog › downloading-a-react-component-as-pdf-12021aaf0ccc
Downloading React Components as PDF Files | Stackademic
December 6, 2023 - TL;DR — Most probably you have encountered articles that would recommend the combination of html2canvas and jsPDF. Even though they’re very good libraries, you may not need them for such a narrow use case. In this article, I will talk about react-to-pdf (ver. 1.0.1), a concise library for downloading React components as PDF files.
🌐
DEV Community
dev.to › jaymeeu › how-to-generate-custom-pdf-using-react-and-react-pdf-6d4
How to Generate Custom PDF, Using React and React-PDF. - DEV Community
February 12, 2024 - BlobProvider: This component generates a PDF document and provides it as a Blob object that can be used to display or download the PDF document. With this out of the way, let's create our PDF. In our project folder, let's create a new file called Invoice.js in the src folder and add code as shown below. import React from 'react' import { Image, Text, View, Page, Document, StyleSheet } from '@react-pdf/renderer'; const Invoice = () => { const reciept_data = { // update reciept_data here } const styles = StyleSheet.create({ // update Invoice styles here }} const InvoiceTitle = () => ( // update
🌐
LogRocket
blog.logrocket.com › home › generating pdfs in react with react-pdf
Generating PDFs in React with react-pdf - LogRocket Blog
January 24, 2025 - wojtekmaj/react-pdf has excellent community support and undergoes constant updates. Additionally, it boasts over 9K+ stars on GitHub and 900K+ weekly downloads on npm.