JavaScript PDF viewer libraries

Updated Nov 2026

JavaScript PDF viewer libraries render PDF pages inside a web page instead of the browser's built-in viewer. A viewer draws each page to a canvas or SVG layer with selectable text above it. These libraries let document portals, contract tools, and AI research apps show, search, and annotate PDFs in their own interface.

Popularity

PDF.js has the most monthly downloads in this comparison, at 205.4M.

LibraryMonthly downloadsStarsLast releaseLicense
PDF.js
211.7M
54.1KNov 2026Apache-2.0
react-pdf
37.3M
11.2KNov 2026MIT
@pdftron/webviewer
2.5M
Not on GitHubOct 2026Commercial
@react-pdf-viewer/core
1.8M
2.6KMar 2023Commercial
ng2-pdf-viewer
1.6M
1.4KDec 2024MIT
ngx-extended-pdf-viewer
1.3M
582Nov 2026Apache-2.0
@embedpdf/snippet
1.2M
4.7KSep 2026MIT
vue-pdf-embed
998.7K
1.0KOct 2026MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Parses and renders PDFs through a JavaScript display API and viewer components.

Downloads / mo
211.7M
Stars
54.1K
Last release
6.5.438
License
Apache-2.0

Strengths

  • Controls page rendering directly. Set the viewport and render each page into a chosen context.
  • Includes a complete viewer layer. Adapt the provided viewer instead of building every control.

Limitations

  • High-resolution pages consume canvas memory. Render visible pages instead of retaining every page canvas.
  • Remote PDFs need server permission. Enable CORS or use an application proxy for cross-origin documents.

Quickstart

From helloworld.html
$ npm install pdfjs-dist
import { getDocument, GlobalWorkerOptions } from 'pdfjs-dist';
GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.mjs', import.meta.url).toString();
const pdf = await getDocument('/example.pdf').promise;
const page = await pdf.getPage(1);
const viewport = page.getViewport({ scale: 1 });
const canvas = document.createElement('canvas');
canvas.width = viewport.width;
canvas.height = viewport.height;
document.body.appendChild(canvas);
await page.render({ canvas, viewport }).promise;

Displays PDF documents and pages inside React applications.

Downloads / mo
37.3M
Stars
11.2K
Last release
11.1.0
License
MIT

Strengths

  • Composes document and page components. Render a Document and choose pages through Page components.
  • Renders text and link layers. Include the text and annotation stylesheets for correctly displayed layers.

Limitations

  • Requires an exactly matching worker. Keep the PDF.js worker and React-PDF dependency versions synchronized.
  • Legacy browsers need bundler configuration. Use the legacy PDF.js main build and viewer module.

Quickstart

From Sample.tsx
$ npm install react-pdf pdfjs-dist@6.5.438 react@19 react-dom@19
import { Document, Page, pdfjs } from 'react-pdf';
import 'react-pdf/dist/Page/AnnotationLayer.css';
import 'react-pdf/dist/Page/TextLayer.css';
pdfjs.GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url).toString();
export default function PdfExample() {
  return <Document file="/example.pdf"><Page pageNumber={1} /></Document>;
}

react-pdf examples

From open-source projects on GitHub

@pdftron/webviewer

Provides a JavaScript document SDK and UI component library from the Apryse PDF SDK.

Downloads / mo
2.5M
Last release
12.2.1
License
Commercial

Quickstart

From README.md
$ npm install @pdftron/webviewer
import WebViewer from '@pdftron/webviewer';
await WebViewer.WebComponent({
  path: '/webviewer/lib',
  initialDoc: '/example.pdf',
  licenseKey: 'YOUR_LICENSE_KEY',
}, document.getElementById('viewer'));

@react-pdf-viewer/core

Displays PDF documents through React components with optional viewer plugins.

Downloads / mo
1.8M
Stars
2.6K
Last release
3.12.0
License
Commercial

Strengths

  • Adds navigation through plugins. Add page controls through the page-navigation or default-layout plugin.
  • Customizes protected-document prompts. Use renderProtectedView to provide a password-entry interface.

Limitations

  • Requires older PDF.js majors. Version 3.12 accepts PDF.js 2 or 3, rather than the latest major.
  • Worker versions must match. Serve a worker matching the installed PDF.js version.

Quickstart

From App.tsx
$ npm install @react-pdf-viewer/core pdfjs-dist@3.11.174 react@18 react-dom@18
import { Viewer, Worker } from '@react-pdf-viewer/core';
import '@react-pdf-viewer/core/lib/styles/index.css';
export default function PdfExample() {
  return <div style={{ height: '600px' }}><Worker workerUrl="https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js"><Viewer fileUrl="/example.pdf" /></Worker></div>;
}

@react-pdf-viewer/core examples

From open-source projects on GitHub

ng2-pdf-viewer

Renders PDFs as an Angular component.

Downloads / mo
1.6M
Stars
1.4K
Last release
10.4.0
License
MIT

Quickstart

From README.md
$ npm install ng2-pdf-viewer
import { Component } from '@angular/core';
import { PdfViewerModule } from 'ng2-pdf-viewer';
@Component({ standalone: true, selector: 'app-pdf-example', imports: [PdfViewerModule], template: '<pdf-viewer [src]="source" [render-text]="true" style="display:block;width:100%;height:600px"></pdf-viewer>' })
export class PdfExample { source = '/example.pdf'; }

ngx-extended-pdf-viewer

Embeds a configurable PDF viewer with toolbar and sidebar in Angular apps.

Downloads / mo
1.3M
Stars
582
Last release
32.0.2
License
Apache-2.0

Quickstart

From README.md
$ ng add ngx-extended-pdf-viewer@32.0.2
import { Component } from '@angular/core';
import { NgxExtendedPdfViewerModule } from 'ngx-extended-pdf-viewer';

@Component({
  selector: 'app-pdf-viewer',
  standalone: true,
  imports: [NgxExtendedPdfViewerModule],
  template: `<ngx-extended-pdf-viewer [src]="'assets/example.pdf'"></ngx-extended-pdf-viewer>`,
})
export class PdfViewerComponent {}

@embedpdf/snippet

Adds a ready PDF viewer to a web app.

Downloads / mo
1.2M
Stars
4.7K
Last release
2.15.1
License
MIT

Quickstart

From README.md
$ npm install @embedpdf/snippet
<div id="pdf-viewer" style="height: 500px"></div>
<script async type="module">
  import EmbedPDF from 'https://cdn.jsdelivr.net/npm/@embedpdf/snippet@2/dist/embedpdf.js';

  const viewer = EmbedPDF.init({
    type: 'container', // mount strategy
    target: document.getElementById('pdf-viewer'),
    src: 'https://snippet.embedpdf.com/ebook.pdf', // your PDF URL
  });
</script>

@embedpdf/snippet examples

From open-source projects on GitHub

vue-pdf-embed

Embeds PDFs as a Vue component.

Downloads / mo
998.7K
Stars
1.0K
Last release
2.1.7
License
MIT

Quickstart

From README.md
$ npm install vue-pdf-embed vue@^3.3.0
<script setup>
import VuePdfEmbed from 'vue-pdf-embed';
import 'vue-pdf-embed/dist/styles/annotationLayer.css';
import 'vue-pdf-embed/dist/styles/textLayer.css';
const source = '/example.pdf';
</script>
<template><VuePdfEmbed annotation-layer text-layer :source="source" /></template>

FAQ

PDF.js suits apps that build their own viewer on a rendering engine. React-PDF suits React apps that display PDF pages as components. ngx-extended-pdf-viewer suits Angular apps that want a full toolbar and sidebar.

pdfjs-dist is the npm package for PDF.js, the PDF renderer from Mozilla. It parses and renders PDFs through a display API and viewer components.

React-PDF displays PDF documents and pages as React components. React PDF Viewer adds an optional toolbar and other features through plugins.

ngx-extended-pdf-viewer embeds a configurable viewer with a toolbar and sidebar in an Angular app. ng2-pdf-viewer renders PDF pages as an Angular component without a toolbar.

Apryse WebViewer is a commercial JavaScript document SDK with a UI component library. It ships a full viewer toolbar and annotation tools.

For coding agents

Found your PDF viewer library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official