🌐
npm
npmjs.com › package › react-pdf
react-pdf - npm
February 25, 2026 - This package is used to display existing PDFs. If you wish to create PDFs using React, you may be looking for @react-pdf/renderer. Install by executing npm install react-pdf or yarn add react-pdf.
      » npm install react-pdf
    
Published   Feb 25, 2026
Version   10.4.1
Author   Wojciech Maj
🌐
npm
npmjs.com › package › react-pdf-html
react-pdf-html - npm
Html component for react-pdf with CSS support. Latest version: 2.1.5, last published: 3 months ago. Start using react-pdf-html in your project by running `npm i react-pdf-html`. There are 24 other projects in the npm registry using react-pdf-html.
      » npm install react-pdf-html
    
Published   Dec 29, 2025
Version   2.1.5
Author   Dan Blaisdell dan@manifestwebdesign.com
Discussions

reactjs - Generating a PDF file from React Components - Stack Overflow
Besides using the html2canvas and jspdf libraries, I found another simple-to-use library called react-to-print for downloading a React component as a PDF file here https://www.npmjs.com/package/react-to-print. The documentation, examples, and demos are amazing. More on stackoverflow.com
🌐 stackoverflow.com
Node npm package for pdf creation from html
Why not use https://pptr.dev/api/puppeteer.page.pdf More on reddit.com
🌐 r/node
2
3
May 5, 2024
Running create-react-app, npm run build and then opening the index.html file in the build folder does not work?
How did u run it? More on reddit.com
🌐 r/reactjs
22
1
January 21, 2019
React: Could not find a required file
Make sure the public folder is in the correct place. More on reddit.com
🌐 r/learnprogramming
17
4
May 21, 2020
🌐
npm
npmjs.com › package › @react-pdf › renderer
@react-pdf/renderer - npm
3 days ago - Latest version: 4.3.3, last published: 19 hours ago. Start using @react-pdf/renderer in your project by running `npm i @react-pdf/renderer`. There are 489 other projects in the npm registry using @react-pdf/renderer.
      » npm install @react-pdf/renderer
    
Published   Apr 04, 2026
Version   4.3.3
Author   Diego Muracciole
🌐
npm
npmjs.com › package › react-to-pdf
react-to-pdf - npm
3 weeks ago - Create PDF documents from React Components. Latest version: 3.2.2, last published: 19 days ago. Start using react-to-pdf in your project by running `npm i react-to-pdf`. There are 28 other projects in the npm registry using react-to-pdf.
      » npm install react-to-pdf
    
Published   Mar 18, 2026
Version   3.2.2
Author   Marcos Andrei Ivanechtchuk
🌐
npm
npmjs.com › package › @rawwee › react-pdf-html
@rawwee/react-pdf-html - npm
Latest version: 1.2.1, last published: a year ago. Start using @rawwee/react-pdf-html in your project by running `npm i @rawwee/react-pdf-html`. There are no other projects in the npm registry using @rawwee/react-pdf-html.
      » npm install @rawwee/react-pdf-html
    
Published   Oct 05, 2024
Version   1.2.1
Author   Josip Papež
🌐
Nutrient
nutrient.io › blog › sdk › how to convert html to pdf using react
How to convert HTML to PDF in React with jsPDF
February 9, 2026 - If you need flexbox layouts, external fonts, and vector text without html2canvas, @react-pdf/renderer(opens in a new tab) takes a different approach — you define your PDF as React components instead of converting existing HTML. Install it: Terminal window · npm i @react-pdf/renderer ·
🌐
GitHub
github.com › diegomura › react-pdf
GitHub - diegomura/react-pdf: 📄 Create PDF files using React
import React from 'react'; import { Document, Page, Text, View, StyleSheet } from '@react-pdf/renderer'; // Create styles const styles = StyleSheet.create({ page: { flexDirection: 'row', backgroundColor: '#E4E4E4', }, section: { margin: 10, ...
Starred by 16.5K users
Forked by 1.3K users
Languages   TypeScript 84.4% | JavaScript 15.5%
🌐
npm
npmjs.com › package › react-native-html-to-pdf
react-native-html-to-pdf - npm
Latest version: 1.3.0, last published: 6 months ago. Start using react-native-html-to-pdf in your project by running `npm i react-native-html-to-pdf`. There are 19 other projects in the npm registry using react-native-html-to-pdf.
      » npm install react-native-html-to-pdf
    
Published   Sep 04, 2025
Version   1.3.0
Author   Christopher Dro
Find elsewhere
🌐
React-pdf
react-pdf.org
React-pdf
React renderer for creating PDF files on the browser and server
🌐
GitHub
github.com › wojtekmaj › react-pdf
GitHub - wojtekmaj/react-pdf: Display PDFs in your React app as easily as if they were images. · GitHub
This package is used to display existing PDFs. If you wish to create PDFs using React, you may be looking for @react-pdf/renderer. Install by executing npm install react-pdf or yarn add react-pdf.
Starred by 11K users
Forked by 999 users
Languages   TypeScript 94.5% | CSS 5.4% | HTML 0.1%
🌐
npm
npmjs.com › package › @pdf-viewer › react
@pdf-viewer/react - npm
February 16, 2026 - Latest version: 1.19.0, last published: 2 months ago. Start using @pdf-viewer/react in your project by running `npm i @pdf-viewer/react`. There are no other projects in the npm registry using @pdf-viewer/react.
      » npm install @pdf-viewer/react
    
Published   Feb 16, 2026
Version   1.19.0
Author   React PDF Viewer
🌐
npm
npmjs.com › package › @react-pdf › pdfkit
@react-pdf/pdfkit - npm
December 29, 2025 - npm install @react-pdf/pdfkit · Vector graphics · HTML5 canvas-like API · Path operations · SVG path parser for easy path creation · Transformations · Linear and radial gradients · Text · Line wrapping · Text alignments · Bulleted ...
      » npm install @react-pdf/pdfkit
    
Published   Dec 29, 2025
Version   4.1.0
Author   Devon Govett
🌐
GitHub
github.com › mikecousins › react-pdf-js
GitHub - mikecousins/react-pdf-js: A React component to wrap PDF.js
Install with yarn add @mikecousins/react-pdf pdfjs-dist or npm install @mikecousins/react-pdf pdfjs-dist
Starred by 803 users
Forked by 151 users
Languages   TypeScript 90.7% | JavaScript 6.9% | CSS 2.0% | HTML 0.4% | TypeScript 90.7% | JavaScript 6.9% | CSS 2.0% | HTML 0.4%
🌐
Nutrient
nutrient.io › blog › sdk › how to build a reactjs pdf viewer with react pdf
How to build a React PDF viewer with react-pdf (2026)
January 28, 2026 - Install react-pdf (npm install react-pdf), import the Document and Page components, configure the PDF.js worker in the same file, and build your own navigation controls.
Top answer
1 of 13
168

Rendering react as pdf is generally a pain, but there is a way around it using canvas.

The idea is to convert : HTML -> Canvas -> PNG (or JPEG) -> PDF

To achieve the above, you'll need :

  1. html2canvas &
  2. jsPDF

import React, {Component, PropTypes} from 'react';

// download html2canvas and jsPDF and save the files in app/ext, or somewhere else
// the built versions are directly consumable
// import {html2canvas, jsPDF} from 'app/ext';


export default class Export extends Component {
  constructor(props) {
    super(props);
  }

  printDocument() {
    const input = document.getElementById('divToPrint');
    html2canvas(input)
      .then((canvas) => {
        const imgData = canvas.toDataURL('image/png');
        const pdf = new jsPDF();
        pdf.addImage(imgData, 'JPEG', 0, 0);
        // pdf.output('dataurlnewwindow');
        pdf.save("download.pdf");
      })
    ;
  }

  render() {
    return (<div>
      <div className="mb5">
        <button onClick={this.printDocument}>Print</button>
      </div>
      <div id="divToPrint" className="mt4" {...css({
        backgroundColor: '#f5f5f5',
        width: '210mm',
        minHeight: '297mm',
        marginLeft: 'auto',
        marginRight: 'auto'
      })}>
        <div>Note: Here the dimensions of div are same as A4</div> 
        <div>You Can add any component here</div>
      </div>
    </div>);
  }
}

The snippet will not work here because the required files are not imported.

An alternate approach is being used in this answer, where the middle steps are dropped and you can simply convert from HTML to PDF. There is an option to do this in the jsPDF documentation as well, but from personal observation, I feel that better accuracy is achieved when dom is converted into png first.

Update 0: September 14, 2018

The text on the pdfs created by this approach will not be selectable. If that's a requirement, you might find this article helpful.

2 of 13
19

@react-pdf/renderer is a great resource for this.

It is a bit time consuming converting your markup and CSS to React-PDF's format, but it is easy to understand. Exporting a PDF and from it is fairly straightforward.

To allow a user to download a PDF generated by react-PDF, use their on the fly rendering, which provides a customizable download link. When clicked, the site renders and downloads the PDF for the user.

Here's their REPL which will familiarize you with the markup and styling required. They have a download link for the PDF too, but they don't show the code for that here.

🌐
npm
npmjs.com › package › @simplepdf › react-embed-pdf
@simplepdf/react-embed-pdf - npm
January 17, 2026 - import { EmbedPDF } from '@simplepdf/react-embed-pdf'; <EmbedPDF companyIdentifier="yourcompany"> <a href="https://cdn.simplepdf.com/simple-pdf/assets/sample.pdf">Opens sample.pdf</a> </EmbedPDF>; Wrap any HTML element with EmbedPDF to open ...
      » npm install @simplepdf/react-embed-pdf
    
Published   Jan 17, 2026
Version   1.10.0
Author   bendersej
🌐
Nutrient
nutrient.io › blog › sdk › how to convert html to pdf using html2df and react
HTML to PDF in React: Convert HTML to PDF using html2pdf.js
May 7, 2025 - cd html2pdf-react-app · ... it, run the following command inside your project directory: Terminal window · npm install html2pdf.js ·...
🌐
IronPDF
ironpdf.com › ironpdf blog › node pdf tools › html to pdf react
Convert HTML to PDF in React (Developer Tutorial) | IronPDF
January 19, 2026 - Install IronPDF: You can install IronPDF in your React project using npm or yarn. ... Integrate with React Components: You can create React components that utilize IronPDF to generate and manipulate PDFs.
🌐
Npm
npm.io › package › react-pdf-html
React-pdf-html NPM | npm.io
January 1, 2018 - const html = `<div style="width: 200px; height: 200px; background-color: pink">Foobar</div>`; return ( <Document> <Page> <Html>{html}</Html> </Page> </Document> ); Remote styles must be resolve asynchronously, outside of the React rendering, because react-pdf doesn't support asynchronous rendering