The following approach worked for me.

import ExampleDoc from '......src/assets/files/exampleDoc.pdf'

<a href={ExampleDoc} download="MyExampleDoc" target='_blank'>
   <Button className={classes.navLink}>My Example Doc</Button>
</a>
Answer from Sai Lakshmy on Stack Overflow
🌐
GitHub
github.com › diegomura › react-pdf › issues › 975
download pdf on custom button click · Issue #975 · diegomura/react-pdf
August 13, 2020 - diegomura / react-pdf Public · There was an error while loading. Please reload this page. Notifications · You must be signed in to change notification settings · Fork 1.3k · Star 16.5k · New issueCopy link · New issueCopy link · Closed · #1902 · Closed · download pdf on custom button click #975 ·
Author   pradeepn541
🌐
React-pdf
react-pdf.org › advanced
React-pdf
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!'
Discussions

html - Download file by clicking a button in ReactJS - Stack Overflow
I have a website built with ReactJS and there are some files (PDF,DOC etc) that I want to let visitors download. But simple href tag doesn't start the download, instead refresh the page. More on stackoverflow.com
🌐 stackoverflow.com
reactjs - How do I download a pdf file onClick with react-pdf? - Stack Overflow
I want to generate a pdf from the UI and download it. Been looking to the documentation but couldn't find how to implement I.e. onClick={this.downloadPdf} here's the module reference: https://github.com/diegomura/react-pdf More on stackoverflow.com
🌐 stackoverflow.com
How to generate a PDF and download it without rendering it?
I was trying to generate a PDF with some layout. I have configured the values using hooks, but I want to download the generated PDF without rendering it to the client side. How can I achieve this w... More on github.com
🌐 github.com
2
1
How to render AND download on link clink, without rendering on page load
I have an application that generates a pdf based on the current state of the application when the user clicks a button. I'd like to use react-pdf, but I'm not sure how to make it work, since the default behavior seems to be to generate the pdf on page load and then only download it when the ... More on github.com
🌐 github.com
2
1
October 1, 2022
🌐
Medium
medium.com › mindroast › step-by-step-guide-how-to-add-a-download-button-to-save-react-component-as-pdf-bc680e59c817
Step-by-Step Guide: How to Add a Download Button to Save React Component as PDF | by Apoorv | Mindroast | Medium
October 22, 2023 - In the `handleDownloadPDF` function, ... is then added to a PDF using `jsPDF`. When the user clicks the “Download PDF” button, the PDF file will be generated and downloaded automatically....
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › how-to-download-pdf-file-in-reactjs
How To Download PDF file in ReactJS? - GeeksforGeeks
import React from "react"; const App = () => { const onButtonClick = () => { const pdfUrl = "Sample.pdf"; const link = document.createElement("a"); link.href = pdfUrl; link.download = "your file name.pdf"; document.body.appendChild(link); link.click(); document.body.removeChild(link); }; return ( <> <center> <h1>Welcome to Geeks for Geeks</h1> <h3> Click on below button to download PDF file </h3> <button onClick={onButtonClick}> Download PDF </button> </center> </> ); }; export default App;
Published   July 23, 2025
🌐
Freddydiengott
freddydiengott.com › blogs › pdf-react
Downloading (and displaying) PDFs in React
November 20, 2024 - This is important, because by using ... issue. In our downloadPDF event handler, we do a few things: we use react-pdf's pdf function to render our pdf and convert it into a blob with the toBlob() method....
Find elsewhere
🌐
React PDF Viewer
react-pdf-viewer.dev › examples › customize-the-download-button
Customize the download button - React PDF Viewer
The `Download` component provided by the Get File plugin has a render prop that allows consumers to use a custom button. Here is the sample code that demonstrates the ability: import { RenderDownloadProps } from '@react-pdf-viewer/get-file';
🌐
React PDF Viewer
react-pdf-viewer.dev › examples › use-the-default-download-button
Use the default download button - React PDF Viewer
The following example uses the default download button `<DownloadButton />` provided by the Get File plugin.
🌐
Syncfusion
ej2.syncfusion.com › documentation › document processing › pdf › pdf viewer › react › 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
🌐
DEV Community
dev.to › apoorvtomar › step-by-step-guide-how-to-add-a-download-button-to-save-react-component-as-pdf-3gie
Step-by-Step Guide: How to Add a Download Button to Save React Component as PDF - DEV Community
October 22, 2023 - In the handleDownloadPDF function, ... clicks the “Download PDF” button, the PDF file will be generated and downloaded automatically. By following these steps, you can seamlessly implement a PDF download feature for HTML pages or React ...
🌐
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 - Next, let's implement the actions button functionalities. To download PDF we will be using a custom hook PDFDownloadLink from React-PDF. This component creates a download link for a PDF document generated by the react-pdf library.
🌐
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 - We will create a button that generates multiple PDFs when clicked, using the BlobProvider component from @react-pdf/renderer. Here’s how to create and download multiple PDFs:
🌐
JavaScript in Plain English
javascript.plainenglish.io › how-to-download-files-on-button-click-reactjs-f7257e55a26b
How to Create a Download Button Using React | JavaScript in Plain English
July 16, 2024 - When I was building 100 Ideas, I wanted to give users an option to export their content in a text file. It was super simple. This post is an attempt to share that knowledge and log it for the future. Assuming you already know the basics of React, let's begin. <div className="btnDiv"> <button id="downloadBtn" value="download">Download</button> </div>
🌐
Mdfaisal
mdfaisal.com › blog › download-html-as-a-pdf-in-react
Download HTML as a PDF in React - Blog | Mohammad Faisal
February 18, 2021 - import React from 'react'; import html2canvas from "html2canvas"; import { jsPDF } from "jspdf"; const GenericPdfDownloader = ({rootElementId , downloadFileName}) => { const downloadPdfDocument = () => { const input = document.getElementById(rootElementId); html2canvas(input) .then((canvas) => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF(); pdf.addImage(imgData, 'JPEG', 0, 0); pdf.save(`${downloadFileName}.pdf`); }) } return <button onClick={downloadPdfDocument}>Download Pdf</button> } export default GenericPdfDownloader; Now you can just place this component anywhere
🌐
Stackademic
stackademic.com › blog › downloading-a-react-component-as-pdf-12021aaf0ccc
Downloading React Components as PDF Files | Stackademic
December 6, 2023 - You probably will not need this and things can break, // so use with caution. overrides: { // see https://artskydj.github.io/jsPDF/docs/jsPDF.html for more options pdf: { compress: true }, // see https://html2canvas.hertzen.com/configuration for more options canvas: { useCORS: true } }, }; // you can use a function to return the target element besides using React refs const getTargetElement = () => document.getElementById('content-id'); const Component = () => { return ( <div> <button onClick={() => generatePDF(getTargetElement, options)}> Generate PDF </button> <div id="content-id"> Content to be generated to PDF </div> </div> ); } Here is a demo provided in the react-to-pdf documentation via Code Sandbox. I would also like to mention that the code blocks above are also from the documentation. Like me, you may need to let your users download PDF files generated from components.