npm
npmjs.com › package › react-pdf
react-pdf - npm
Latest version: 10.2.0, last published: 2 months ago. Start using react-pdf in your project by running `npm i react-pdf`. There are 985 other projects in the npm registry using react-pdf.
» npm install react-pdf
Published Oct 09, 2025
Version 10.2.0
Author Wojciech Maj
Repository https://github.com/wojtekmaj/react-pdf
npm
npmjs.com › package › react-pdf-js
react-pdf-js - npm
Latest version: 5.1.0, last published: 6 years ago. Start using react-pdf-js in your project by running `npm i react-pdf-js`. There are 31 other projects in the npm registry using react-pdf-js.
» npm install react-pdf-js
Published Jun 19, 2019
Version 5.1.0
Author mikecousins
Repository https://github.com/mikecousins/react-pdf-js
Videos
14:28
This React PDF-Viewer Component Is Amazing! - YouTube
15:35
How to generate PDF in React using React pdf - YouTube
10:48
How to generate a PDF from a React component - YouTube
09:06
How to View Pdf in React using React PDF || React PDF Viewer || ...
React-PDF : PDF Viewer in React JS - YouTube
13:10
How to View PDFs in React JS with React PDF Viewer - YouTube
GitHub
github.com › mikecousins › react-pdf-js
GitHub - mikecousins/react-pdf-js: A React component to wrap PDF.js
react-pdf-js provides a component for rendering PDF documents using PDF.js. ... Install with yarn add @mikecousins/react-pdf pdfjs-dist or npm install @mikecousins/react-pdf pdfjs-dist
Starred by 799 users
Forked by 151 users
Languages TypeScript 90.7% | JavaScript 6.9% | CSS 2.0% | HTML 0.4%
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.
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 10.7K users
Forked by 981 users
Languages TypeScript 94.3% | CSS 5.6% | HTML 0.1%
npm
npmjs.com › package › @react-pdf › renderer
@react-pdf/renderer - npm
Latest version: 4.3.1, last published: 3 months ago. Start using @react-pdf/renderer in your project by running `npm i @react-pdf/renderer`. There are 446 other projects in the npm registry using @react-pdf/renderer.
» npm install @react-pdf/renderer
Published Sep 23, 2025
Version 4.3.1
Author Diego Muracciole
Repository https://github.com/diegomura/react-pdf
npm
npmjs.com › package › react-to-pdf
react-to-pdf - npm
Create PDF documents from React Components. Latest version: 2.0.3, last published: 17 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 Nov 25, 2025
Version 2.0.3
Author Marcos Andrei Ivanechtchuk
Repository https://github.com/ivmarcos/react-to-pdf
npm
npmjs.com › package › @pdf-viewer › react
@pdf-viewer/react - npm
Latest version: 1.13.1, last published: 5 days 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
npm
npmjs.com › package › @mikecousins › react-pdf
@mikecousins/react-pdf - npm
Latest version: 8.0.1, last published: 6 months ago. Start using @mikecousins/react-pdf in your project by running `npm i @mikecousins/react-pdf`. There are 11 other projects in the npm registry using @mikecousins/react-pdf.
» npm install @mikecousins/react-pdf
Published Mar 28, 2025
Version 8.0.1
Author mikecousins
Repository https://github.com/mikecousins/react-pdf-js
npm
npmjs.com › package › @react-pdf-viewer › core
@react-pdf-viewer/core - npm
Latest version: 3.12.0, last published: 3 years ago. Start using @react-pdf-viewer/core in your project by running `npm i @react-pdf-viewer/core`. There are 167 other projects in the npm registry using @react-pdf-viewer/core.
» npm install @react-pdf-viewer/core
npm
npmjs.com › package › jspdf-react
jspdf-react - npm
Wrapper jsPDF for React. Latest version: 1.0.11, last published: 6 years ago. Start using jspdf-react in your project by running `npm i jspdf-react`. There are 7 other projects in the npm registry using jspdf-react.
» npm install jspdf-react
npm
npmjs.com › package › react-view-pdf
react-view-pdf - npm
Latest version: 1.0.0, last published: 4 years ago. Start using react-view-pdf in your project by running `npm i react-view-pdf`. There are no other projects in the npm registry using react-view-pdf.
» npm install react-view-pdf
Published Nov 24, 2021
Version 1.0.0
Author ZEISS Digital Innovation Partners
Repository https://github.com/ZEISS/react-view-pdf
npm
npmjs.com › package › react-pdf-html
react-pdf-html - npm
Parses the HTML string into a JSON tree of nodes using node-html-parser · Parses any <style> tags in the document and style attributes using css-tree · Renders all nodes using the appropriate react-pdf components, applying cascading styles ...
» npm install react-pdf-html
Published Jan 15, 2025
Version 2.1.3
Author Dan Blaisdell [email protected]
Repository https://github.com/danomatic/react-pdf-html
Top answer 1 of 5
25
I spent too much time today, piecing together fragments of other answers to this question. So here is a complete answer.
First you install pdfjs-dist:
npm install pdfjs-dist
And here is how to use it in an actual viewer component:
import React, { useEffect, useState, useRef, useCallback } from 'react';
import pdfjsLib from "pdfjs-dist/build/pdf";
import pdfjsWorker from "pdfjs-dist/build/pdf.worker.entry";
export default function PdfViewer({url}){
const canvasRef = useRef();
pdfjsLib.GlobalWorkerOptions.workerSrc = pdfjsWorker;
const [pdfRef, setPdfRef] = useState();
const [currentPage, setCurrentPage] = useState(1);
const renderPage = useCallback((pageNum, pdf=pdfRef) => {
pdf && pdf.getPage(pageNum).then(function(page) {
const viewport = page.getViewport({scale: 1.5});
const canvas = canvasRef.current;
canvas.height = viewport.height;
canvas.width = viewport.width;
const renderContext = {
canvasContext: canvas.getContext('2d'),
viewport: viewport
};
page.render(renderContext);
});
}, [pdfRef]);
useEffect(() => {
renderPage(currentPage, pdfRef);
}, [pdfRef, currentPage, renderPage]);
useEffect(() => {
const loadingTask = pdfjsLib.getDocument(url);
loadingTask.promise.then(loadedPdf => {
setPdfRef(loadedPdf);
}, function (reason) {
console.error(reason);
});
}, [url]);
const nextPage = () => pdfRef && currentPage < pdfRef.numPages && setCurrentPage(currentPage + 1);
const prevPage = () => currentPage > 1 && setCurrentPage(currentPage - 1);
return <canvas ref={canvasRef}></canvas>;
}
2 of 5
9
This import will clear the undefined issue:
import * as pdfjsLib from "pdfjs-dist/build/pdf";
React PDF Viewer
react-pdf-viewer.dev › docs › getting-started
Getting started - React PDF Viewer
npm install [email protected] · The `pdfjs-dist` will be added to the `dependencies` section in `package.json`: { "dependencies": { "pdfjs-dist": "^3.4.120" } } If the installed version of `pdfjs-dist` requires the canvas package which has issues with Apple M1.
PDF.js Express
pdfjs.express › documentation › get-started › react
Integrate React & JavaScript PDF Viewer | PDF.js Express SDK
const MyComponent = () => { const viewer = useRef(null); useEffect(() => { WebViewer( { path: '/webviewer/lib', initialDoc: '/files/pdftron_about.pdf', }, viewer.current, ).then((instance) => { }); }, []); return ( <div className="MyComponent"> <div className="header">React sample</div> <div className="webviewer" ref={viewer}></div> </div> ); }; Run the app by running npm start.
GitHub
github.com › erikras › react-pdfjs
GitHub - erikras/react-pdfjs: A React component to wrap PDF.js
react-pdfjs provides a component for rendering PDF documents using PDF.js. npm install --save react-pdfjs · This project will not be supported. It is a port of react-pdf to ES6 and React 0.14.
Starred by 82 users
Forked by 25 users
Languages JavaScript
Stack Overflow
stackoverflow.com › questions › 73919619 › how-to-use-pdf-js-with-react
reactjs - How to use PDF.JS with React? - Stack Overflow
export default function Home() { const [data, setData] = useState(); const handleFile = (e) => { const file = e.target.files[0]; const fileReader = new FileReader(); fileReader.onload = (d) => { setData(new Uint32Array(d.target.result)); }; }; return ( <> <h1>hello!</h1> <input type="file" accept="application/pdf" placeholder="insert PDF here" onChange={(e) => handleFile(e)} /> <PDFViewer pdfFile={data} /> </> ); }