🌐
PDF.js Express
pdfjs.express › documentation › get-started › react
Integrate React & JavaScript PDF Viewer | PDF.js Express SDK
const MyComponent = () => { const viewer = useRef(null); return ( <div className="MyComponent"> <div className="header">React sample</div> <div className="webviewer" ref={viewer}></div> </div> ); }; Inside of useEffect hook or componentDidMount lifecycle method initialize WebViewer. Ensure that the path property in the constructor points to where you copied static assets node_modules/@pdftron/pdfjs-express/public in React public folder.
🌐
PDF.js Express
pdfjs.express › documentation › react
React PDF.js Viewer: Annotate, Form Fill, Sign | PDF.js Express
PDF.js Express is a commercial PDF web viewer that wraps around the PDF.js open-source rendering engine. It offers developers a way to quickly add annotation, e-signatures, and form filling to their React PDF viewer.
🌐
PDF.js Express
pdfjs.express › documentation › get-started-viewer › react
Integrate React & JavaScript PDF Viewer | PDF.js Express Viewer SDK
This guide will help you integrate PDF.js Express Viewer into a React application on the browser.
🌐
GitHub
github.com › pdfjs-express › pdfjs-express-react-sample
GitHub - pdfjs-express/pdfjs-express-react-sample
PDF.js Express is a powerful JavaScript-based PDF Library that leverages PDF.js and adds additional features such as annotations, form support, and digitial signatures. It provides a slick out-of-the-box responsive UI that interacts with the ...
Starred by 5 users
Forked by 12 users
Languages   JavaScript 48.8% | HTML 39.0% | CSS 12.2%
🌐
React-pdf
react-pdf.org
React-pdf
React renderer for creating PDF files on the browser and server
🌐
PDF Association
pdfa.org › building-pdf-js-express
Building PDF.js Express – PDF Association
Announcing PDF.js Express, a commercial viewer that wraps a modern React UI around the PDF.js rendering engine to enable PDF annotations, form filling, and signing inside a web app.
🌐
npm
npmjs.com › package › react-pdf
react-pdf - npm
Display PDFs in your React app as easily as if they were images. This package is used to display existing PDFs.
      » npm install react-pdf
    
Published   Oct 09, 2025
Version   10.2.0
Author   Wojciech Maj
🌐
GitHub
github.com › pdfjs-express › pdfjs-express-viewer-react-sample
GitHub - pdfjs-express/pdfjs-express-viewer-react-sample
PDF.js Express Viewer is a powerful JavaScript-based PDF Library. It provides a slick, responsive and customizable UI that out-of-the-box interacts with the core library to view PDFs and is ready to be embedded into any web project.
Starred by 6 users
Forked by 7 users
Languages   JavaScript 54.3% | HTML 34.8% | CSS 10.9%
Find elsewhere
🌐
GitHub
github.com › pdfjs-express
PDF.js Express · GitHub
A simple Bootstrap website with a PDF.js viewer · JavaScript 6 4 · pdfjs-express-viewer-react-sample · pdfjs-express-viewer-react-sample Public · JavaScript 6 7 · pdfjs-express-react-sample · pdfjs-express-react-sample Public · JavaScript 5 12 · Showing 10 of 25 repositories ·
🌐
Exportsdk
exportsdk.com › how-to-generate-pdfs-with-nodejs
How to Generate PDFs with NodeJS and React PDF | Export SDK
Note: To parse JSON objects from our POST requests, we configure Express to use its express.json() function. Next, we'll create a file with a template and a function to generate our PDF (make sure you’re still in the src folder). ... Open create-template.tsx and add the following. import React from "react"; import ReactPDF, { Page, Text, View, Document, StyleSheet, } from "@react-pdf/renderer";
🌐
npm
npmjs.com › package › react-pdf-js
react-pdf-js - npm
Simple React component to wrap up PDF.js. The easiest way to render PDFs in your React app.. 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
🌐
PDF.js Express
pdfjs.express › blog › how-to-build-pdf-viewer-typescript-pdf-js
How to Build a PDF Viewer with TypeScript & PDF.js | Apryse
September 3, 2019 - PDF.js Express wraps a modern react-based UI around the open source PDF.js rendering engine. It includes out-of-the-box features like annotations, form filling and e-signatures, and the viewer is commercially supported.
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";
🌐
GitHub
github.com › mikecousins › react-pdf-js
GitHub - mikecousins/react-pdf-js: A React component to wrap PDF.js
import React, { useState, useRef } from 'react'; import { usePdf } from '@mikecousins/react-pdf'; const MyPdfViewer = () => { const [page, setPage] = useState(1); const canvasRef = useRef(null); const { pdfDocument, pdfPage } = usePdf({ file: 'test.pdf', page, canvasRef, }); return ( <div> {!pdfDocument && <span>Loading...</span>} <canvas ref={canvasRef} /> {Boolean(pdfDocument && pdfDocument.numPages) && ( <nav> <ul className="pager"> <li className="previous"> <button disabled={page === 1} onClick={() => setPage(page - 1)}> Previous </button> </li> <li className="next"> <button disabled={page === pdfDocument.numPages} onClick={() => setPage(page + 1)} > Next </button> </li> </ul> </nav> )} </div> ); };
Starred by 799 users
Forked by 151 users
Languages   TypeScript 90.7% | JavaScript 6.9% | CSS 2.0% | HTML 0.4%
🌐
Tabnine
tabnine.com › home page › code › javascript › react-pdf
react-pdf JavaScript and Node.js code examples | Tabnine
render() { const { pageNumber, numPages, pdfBlob, localPdfBlob } = this.state; return ( <div> <button type="button" onClick={() => this.decrement()}> Prev </button> <button type="button" onClick={() => this.increment()}> Next </button> <Document file={pdfBlob} onLoadSuccess={this.onDocumentLoadSuccess}> <Page scale={0.2} pageNumber={pageNumber} /> </Document> <Document file={localPdfBlob} onLoadSuccess={this.onDocumentLoadSuccess} > <Page scale={0.2} pageNumber={pageNumber} /> </Document> <p> Page {pageNumber} of {numPages} </p> </div> ); } origin: pxFIN/react-router-express-node-example ·
🌐
CodeSandbox
codesandbox.io › examples › package › @pdftron › pdfjs-express
@pdftron/pdfjs-express examples - CodeSandbox
webviewer-react-sample · custom-annotation-samplesA repo containing examples on creating custom annotations in PDF.js Express · pdfjs-express-cors-sampleA sample showing how to use Express when loaded from another domain · pdf-vue · webviewer-vue-sample ·
🌐
GitHub
github.com › wojtekmaj › react-pdf
GitHub - wojtekmaj/react-pdf: Display PDFs in your React app as easily as if they were images.
Add React-PDF to your project by executing npm install react-pdf or yarn add react-pdf. If you use Next.js prior to v15 (v15.0.0-canary.53, specifically), you may need to add the following to your next.config.js:
Starred by 10.7K users
Forked by 981 users
Languages   TypeScript 94.3% | CSS 5.6% | HTML 0.1%
🌐
PDF.js Express
pdfjs.express
PDF.js Viewer: Annotate, Form Fill | Easy Setup | PDF.js Express
PDF.js Express Plusplay_arrow · Professional PDF.js Viewing & Annotations - Try for free · Pick a framework · React · Angular · Vue · Svelte · Blazor · Manual · NPM · Get Started · Documentation · Our SDK is simple and headache-free. Integrating a fully featured PDF viewer in your project takes just a few steps.
🌐
Medium
medium.com › free-code-camp › how-to-generate-dynamic-pdfs-using-react-and-nodejs-eac9e9cb4dde
How to Generate Dynamic PDFs Using React and NodeJS | by Adrian Hajdin | We’ve moved to freeCodeCamp.org/news | Medium
February 5, 2019 - Create a new directory mkdir pdfGenerator && cd pdfGenerator · Create a new React App with create-react-app client and then move into newly created directory and install dependencies cd client && npm i -S axios file-saver · Create an Express server with mkdir server && cd server && touch index.js && npm init press enter a couple of times to initialize package.json and then run npm i -S express body-parser cors html-pdf to save all the necessary dependencies.