hey @geeky01adarsh, I believe you just don't want to display it right? In that case, you could use the @react-pdf/renderers pdf method and the file-saver package to achieve this.

import React from 'react';
import { saveAs } from 'file-saver';
import { pdf } from '@react-pdf/renderer';
import YourDocument from './YourDocument';

const DownloadButton = () => {
  const downloadPdf = async () => {
    const fileName = 'test.pdf';
    const blob = await pdf(<YourDocument />).toBlob();
    saveAs(blob, fileName);
  };

  return <button onClick={downloadPdf}>Download PDFbutton>;
};

export default DownloadButton;

this will convert your pdf component into a Blob and then saves it using saveAs method from file-saver

🌐
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
🌐
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
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.

🌐
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
🌐
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
Find elsewhere
🌐
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%
🌐
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%
🌐
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 ·
🌐
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.
🌐
Reddit
reddit.com › r/reactjs › how to download the official react documentation as a single pdf file?
r/reactjs on Reddit: How to download the official React documentation as a single pdf file?
June 24, 2025 -

How to download the latest official React documentation as a single pdf file?

I know how to print to pdf but that's one page at a time.
I know there's code in the docs and sometimes in tabs. This will get lost in the pdf. I don't care.
I know I can develop a crawler and the crawler can save each page but that's work for me.

I want a ready-made solution. Perhaps someone has already done this work.

🌐
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.
🌐
Wojtekmaj
projects.wojtekmaj.pl › react-pdf
React-PDF
Easily display PDFs in your React app.
🌐
Nutrient
nutrient.io › blog › sdk › how to create pdfs with react to pdf
How to create PDFs with React to PDF
June 17, 2025 - Want to let users download receipts, reports, or certificates as PDFs from your React app without needing a backend? In this tutorial, you’ll use the React to PDF package with Vite to convert JSX components into downloadable PDF files entirely on the client side.
🌐
Freddydiengott
freddydiengott.com › blogs › pdf-react
Downloading (and displaying) PDFs in React
To start, I must acknowledge that I know of no other way to download pdf files on the modern web with javascript without an external package. So that is what we're going to do! The best one I've seen is React-pdf, which provides a pretty straight-forward API for building custom-styled PDF files with React code.
🌐
React PDF Viewer
react-pdf-viewer.dev › plugins › get-file
Get File plugin - React PDF Viewer
The `get-file` plugin provides a button that can be used to download the PDF document.