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

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

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
PDFDownloadLink does not create href in the Download button
My code works like charm in the dev box, but after deploying it to the prod box, I see a "TypeError: a is not a function", Not sure what this means and need help. Attached the error image. using "@... More on github.com
🌐 github.com
4
February 12, 2024
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
Generate PDF on the fly
This is what I am trying to solve currently and wondering if it is/will be possible with react-pdf: I need to be able to generate loads of different PDFs in our platform and would love to do that fully on the frontend. The user clicks download button which allows him to download a generated ... More on github.com
🌐 github.com
62
May 30, 2017
🌐
GitHub
github.com › ivmarcos › react-to-pdf
GitHub - ivmarcos/react-to-pdf: Generate pdf from react components · GitHub
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 ·
Starred by 341 users
Forked by 68 users
Languages   TypeScript 86.4% | Shell 7.1% | JavaScript 5.5% | HTML 1.0%
🌐
GitHub
github.com › diegomura › react-pdf › issues › 2634
PDFDownloadLink does not create href in the Download button · Issue #2634 · diegomura/react-pdf
February 12, 2024 - import { PDFDownloadLink, Document,View, Text, Page } from '@react-pdf/renderer'; <Document> <Page> <View> <Text>test doc</Text> </View> </Page> </Document> PDFDownloadLink in another component: <PDFDownloadLink document={} fileName="somename.pdf"> {({ blob, url, loading, error }) => loading ? 'Loading document...' : 'Download now!'
Author   vikasdinavahi
🌐
React-pdf
react-pdf.org › advanced
React-pdf
import { usePDF, Document, Page } from '@react-pdf/renderer'; const MyDoc = ( <Document> <Page> // My document data </Page> </Document> ); const App = () => { const [instance, updateInstance] = usePDF({ document: MyDoc }); if (instance.loading) return <div>Loading ...</div>; if (instance.error) return <div>Something went wrong: {instance.error}</div>; return ( <a href={instance.url} download="test.pdf"> Download </a> ); }
Find elsewhere
🌐
npm
npmjs.com › package › react-pdf
react-pdf - npm
February 25, 2026 - React-PDF is under constant development. This documentation is written for React-PDF 10.x branch. If you want to see documentation for other versions of React-PDF, use dropdown on top of GitHub page to switch to an appropriate tag.
      » npm install react-pdf
    
Published   Feb 25, 2026
Version   10.4.1
Author   Wojciech Maj
🌐
GitHub
github.com › diegomura › react-pdf › issues › 84
Generate PDF on the fly · Issue #84 · diegomura/react-pdf
May 30, 2017 - This is what I am trying to solve currently and wondering if it is/will be possible with react-pdf: I need to be able to generate loads of different PDFs in our platform and would love to do that fully on the frontend. The user clicks download button which allows him to download a generated ...
Published   May 30, 2017
Author   knowbody
🌐
GitHub
github.com › diegomura › react-pdf › issues › 957
How to generate multiple pdf on a click of button and download it as zip · Issue #957 · diegomura/react-pdf
July 26, 2020 - How to generate multiple pdf on client side using react pdf and when the download gets complete of all the files it should download it as a zip . This operation should be performed on client side o...
Author   Akshaykapadi
🌐
Freddydiengott
freddydiengott.com › blogs › pdf-react
Downloading (and displaying) PDFs in React
November 20, 2024 - We have a PDF that we can download, albeit a simple one, but as it stands, to develop the PDF we would need to click the button and download our file over and over again after any change we want to see. Not ideal. So, to make this better we are going to use PDFViewer from @react-pdf/renderer to display the PDF.
🌐
GitHub
github.com › diegomura › react-pdf › issues › 533
Better examples to implement react-pdf, specifically downloading pdf or opening in browser · Issue #533 · diegomura/react-pdf
March 16, 2019 - Specifically, my problem is I would like a button that generates the pdf of a component. But, here is the recommended code from the doc: 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> )
Author   foureyedraven
🌐
GitHub
github.com › diegomura › react-pdf
GitHub - diegomura/react-pdf: 📄 Create PDF files using React
📄 Create PDF files using React. Contribute to diegomura/react-pdf development by creating an account on GitHub.
Starred by 16.5K users
Forked by 1.3K users
Languages   TypeScript 84.2% | JavaScript 15.7%
🌐
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> ); }
🌐
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 - The image below shows the screenshot of a sample PDF invoice we will design for this project. The image below shows a preview of this project. Each invoice sample has download, print, and share buttons. ... Basic knowledge of JavaScript and ReactJS. Knowledge of CSS Flexbox property. The source code of the project is available on GitHub...
🌐
GitHub
github.com › diegomura › react-pdf › issues › 736
PDFDownloadLink should generate pdf on click · Issue #736 · diegomura/react-pdf
October 14, 2019 - Describe alternatives you've considered I've used pdf() function to generate the blob and file-saver lib to download it: import { saveAs } from 'file-saver'; import { pdf } from '@react-pdf/renderer'; import PdfDocument from '../PdfDocument'; const generatePdfDocument = async (documentData) => { const blob = await pdf(( <PdfDocument title='My PDF' pdfDocumentData={documentData} /> )).toBlob(); saveAs(blob, fileName); }; export default generatePdfDocument;``` Reactions are currently unavailable ·
Author   tomasmatulis0
🌐
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 - Step-by-Step Guide: How to Add a Download Button to Save React Component as PDF In numerous scenarios, it becomes essential to provide users with the ability to download an HTML page or a React …
🌐
GitHub
github.com › HugoCapocci › react-download-button
GitHub - HugoCapocci/react-download-button: A button to allow download file when clicked, whatever the action, even after HTTP POST · GitHub
import DownloadButton from 'react-dfb'; // you can also import flow type if needed import type { DownloadData } from 'react-dfb'; Two required props: onClick: Function to call on button click · downloadData: Object having html5 file informations ...
Author   HugoCapocci
🌐
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.