# JavaScript PDF viewer libraries

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

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [PDF.js](#pdf-js) | 211.7M | 54.1K | Nov 2026 | Apache-2.0 |
| [react-pdf](#react-pdf) | 37.3M | 11.2K | Nov 2026 | MIT |
| [@pdftron/webviewer](#pdftron-webviewer) | 2.5M | Not on GitHub | Oct 2026 | Commercial |
| [@react-pdf-viewer/core](#react-pdf-viewer) | 1.8M | 2.6K | Mar 2023 | Commercial |
| [ng2-pdf-viewer](#ngtwo-pdf-viewer) | 1.6M | 1.4K | Dec 2024 | MIT |
| [ngx-extended-pdf-viewer](#ngx-extended-pdf-viewer) | 1.3M | 582 | Nov 2026 | Apache-2.0 |
| [@embedpdf/snippet](#embedpdf-snippet) | 1.2M | 4.7K | Sep 2026 | MIT |
| [vue-pdf-embed](#vue-pdf-embed) | 998.7K | 1.0K | Oct 2026 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[PDF.js](#pdf-js) has the most monthly downloads in this comparison, at 205.4M.

## Capabilities

| Library | Full viewer toolbar | New ink/free-text annotations |
| --- | --- | --- |
| [PDF.js](#pdf-js) | No | Yes |
| [react-pdf](#react-pdf) | No | No |
| [@pdftron/webviewer](#pdftron-webviewer) | Yes | Yes |
| [@react-pdf-viewer/core](#react-pdf-viewer) | Via plugin | No |
| [ng2-pdf-viewer](#ngtwo-pdf-viewer) | No | No |
| [ngx-extended-pdf-viewer](#ngx-extended-pdf-viewer) | Yes | Yes |
| [@embedpdf/snippet](#embedpdf-snippet) | Yes | Yes |
| [vue-pdf-embed](#vue-pdf-embed) | No | No |

## Libraries

### PDF.js

[GitHub](https://github.com/mozilla/pdf.js) · [npm](https://www.npmjs.com/package/pdfjs-dist) · [Docs](https://mozilla.github.io/pdf.js/)

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
- Capabilities: [From the PDF.js docs](https://mozilla.github.io/pdf.js/)

**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.

**Watch out for**

- **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.

```sh
npm install pdfjs-dist
```

**Quickstart**

```javascript
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;

```

From [helloworld.html](https://cdn.jsdelivr.net/npm/pdfjs-dist@6.5.438/types/src/display/api.d.ts) · [Find projects using PDF.js →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20React%20application%20projects%20using%20pdfjs-dist%20for%20PDF%20page%20rendering%2C%20viewing%2C%20page%20navigation%2C%20text%20selection%20and%20document%20errors&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

### react-pdf

[GitHub](https://github.com/wojtekmaj/react-pdf) · [npm](https://www.npmjs.com/package/react-pdf) · [Docs](https://github.com/wojtekmaj/react-pdf#readme)

Displays PDF documents and pages inside React applications.

- Downloads / mo: 37.3M
- Stars: 11.2K
- Last release: 11.1.0
- License: MIT
- Capabilities: [From the react-pdf docs](https://github.com/wojtekmaj/react-pdf#readme)

**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.

**Watch out for**

- **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.

```sh
npm install react-pdf pdfjs-dist@6.5.438 react@19 react-dom@19
```

**ToolJet/ToolJet** (41.2K stars)

[ToolJet/ToolJet](https://github.com/ToolJet/ToolJet) 

```jsx
const renderPDF = () => {
    if (isPasswordPromptClosed)
      return (
        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', flexDirection: 'column' }}>
          <p style={{ marginBottom: '6px' }}>Password prompt closed</p>
          <button
            class="pdf-retry-button"
            data-cy="draggable-widget-button3"
            type="default"
            onClick={() => setIsPasswordPromptClosed(false)}
          >
            <div>
              <div>
                <span>
                  <p class="tj-text-sm">Retry</p>
                </span>
              </div>
            </div>
          </button>
        </div>
      );
    return (
      <Document
        file={url}
        onLoadSuccess={onDocumentLoadSuccess}
        onLoadError={onDocumentLoadError}
        onPassword={onPassword}
        className="pdf-document"
      >
        {Array.from(new Array(numPages), (el, index) => (
          <Page
            pageNumber={index + 1}
            width={scale ? width - 12 : undefined}
            height={scale ? undefined : height}
            key={`page_${index + 1}`}
            inputRef={(el) => (pageRef.current[index] = el)}
          />
        ))}
      </Document>
    );
  };
```

[frontend/src/AppBuilder/Widgets/PDF.jsx](https://github.com/ToolJet/ToolJet/blob/db08a3a221a77cb8a1e0eaeeed9d00db0dda709d/frontend/src/AppBuilder/Widgets/PDF.jsx#L152-L192) · [More projects using react-pdf →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20React%20application%20projects%20using%20react-pdf%20for%20PDF%20page%20rendering%2C%20viewing%2C%20page%20navigation%2C%20text%20selection%20and%20document%20errors&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```jsx
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>;
}

```

From [Sample.tsx](https://github.com/wojtekmaj/react-pdf/blob/main/packages/react-pdf/README.md)

### @pdftron/webviewer

[npm](https://www.npmjs.com/package/@pdftron/webviewer) · [Docs](https://docs.apryse.com/web/guides)

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
- Capabilities: [From the @pdftron/webviewer docs](https://docs.apryse.com/web/guides)

```sh
npm install @pdftron/webviewer
```

**Quickstart**

```javascript
import WebViewer from '@pdftron/webviewer';
await WebViewer.WebComponent({
  path: '/webviewer/lib',
  initialDoc: '/example.pdf',
  licenseKey: 'YOUR_LICENSE_KEY',
}, document.getElementById('viewer'));

```

From [README.md](https://docs.apryse.com/web/guides/get-started/react) · [Find projects using @pdftron/webviewer →](https://dashboard.exa.ai/playground/search?q=%40pdftron/webviewer%20GitHub%20projects)

### @react-pdf-viewer/core

[GitHub](https://github.com/react-pdf-viewer/react-pdf-viewer) · [npm](https://www.npmjs.com/package/@react-pdf-viewer/core) · [Docs](https://react-pdf-viewer.dev)

Displays PDF documents through React components with optional viewer plugins.

- Downloads / mo: 1.8M
- Stars: 2.6K
- Last release: 3.12.0
- License: Commercial
- Capabilities: [From the @react-pdf-viewer/core docs](https://react-pdf-viewer.dev)

**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.

**Watch out for**

- **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.

```sh
npm install @react-pdf-viewer/core pdfjs-dist@3.11.174 react@18 react-dom@18
```

**Zipstack/unstract** (7.5K stars)

[Zipstack/unstract](https://github.com/Zipstack/unstract) 

```jsx
function PdfViewer({ fileUrl, highlightData, currentHighlightIndex, onError }) {
  const newPlugin = defaultLayoutPlugin();
  const pageNavigationPluginInstance = pageNavigationPlugin();
  const { jumpToPage } = pageNavigationPluginInstance;
  const parentRef = useRef(null);

  // Retry key to force re-render when retrying
  const [retryKey, setRetryKey] = useState(0);
  const [loadError, setLoadError] = useState(null);

  // Clear error state when fileUrl changes to prevent stale notifications
  useEffect(() => {
    setLoadError(null);
  }, [fileUrl]);

  const handleRetry = useCallback(() => {
    setRetryKey((prev) => prev + 1);
    setLoadError(null);
  }, []);

  // Notify parent of load errors via useEffect to avoid side effects during render
  useEffect(() => {
    if (loadError && onError) {
      onError(loadError);
    }
  }, [loadError, onError]);

  // Render error fallback for PDF load failures — pure render, no side effects
  const renderError = useCallback(
    (error) => (
      <PdfLoadError
        error={error}
        onRetry={handleRetry}
        reportError={setLoadError}
      />
    ),
    [handleRetry],
  );

  function removeZerosAndDeleteIfAllZero(highlightData) {
    if (Array.isArray(highlightData)) {
      return highlightData
        ?.filter((innerArray) => {
          if (!Array.isArray(innerArray)) {
            return false;
          }
          // Strip 5th element (confidence) if present, keep only first 4 elements
          const coordsOnly =
            innerArray.length >= 5 ? innerArray.slice(0, 4) : innerArray;
          return coordsOnly.some((value) => value !== 0);
        })
        .map((innerArray) => {
          // Return only the first 4 elements (strip confidence)
          return innerArray.length >= 5 ? innerArray.slice(0, 4) : innerArray;
        });
    }
  }

  const processHighlightData = highlightData
    ? removeZerosAndDeleteIfAllZero(highlightData)
    : [];

  const processedHighlightData =
    processHighlightData?.length > 0 ? processHighlightData : [[0, 0, 0, 0]];

  // Determine current highlight data
  const currentHighlightData = useMemo(() => {
    if (
      RenderHighlights &&
      Array.isArray(processedHighlightData) &&
      processedHighlightData?.length > 0
    ) {
      return currentHighlightIndex !== null &&
        currentHighlightIndex < processedHighlightData.length
        ? [processedHighlightData[currentHighlightIndex]]
        : processedHighlightData;
    }
    return null;
  }, [processedHighlightData, currentHighlightIndex]);

  // Always create both plugins at top level to maintain hook order
  const baseHighlightPlugin = highlightPlugin();
  const customHighlightPlugin = highlightPlugin({
    renderHighlights:
      currentHighlightData && RenderHighlights
        ? (props) => (
            <RenderHighlights {...props} highlightData={currentHighlightData} />
          )
        : undefined,
  });

  // Choose which plugin to use
  const highlightPluginInstance = currentHighlightData
    ? customHighlightPlugin
    : baseHighlightPlugin;

  // Jump to page when highlightData changes or when navigating through highlights
  useEffect(() => {
    const cleanedHighlightData = removeZerosAndDeleteIfAllZero(highlightData);
    if (cleanedHighlightData && cleanedHighlightData.length > 0) {
      // Use currentHighlightIndex if provided, otherwise default to first highlight
      const index =
        currentHighlightIndex !== null &&
        currentHighlightIndex < cleanedHighlightData.length
          ? currentHighlightIndex
          : 0;
      const pageNumber = cleanedHighlightData[index][0]; // Get page number from current highlight

      if (pageNumber !== null && pageNumber !== undefined && jumpToPage) {
        setTimeout(() => {
          jumpToPage(pageNumber); // jumpToPage is 0-indexed
        }, 100); // Add a slight delay to ensure proper page rendering
      }
    }
  }, [highlightData, jumpToPage, currentHighlightIndex]); // Changed dependency to highlightData instead of processedHighlightData

  // Show empty state when no URL is provided
  if (!fileUrl) {
    return (
      <div ref={parentRef} className="doc-manager-body pdf-viewer-error">
        <Result
          icon={<FileWarning style={{ color: "var(--warning)" }} />}
          title="No PDF Available"
          subTitle="The PDF document URL is not available. Please ensure the document has been processed correctly."
        />
      </div>
    );
  }

  return (
    <div ref={parentRef} className="doc-manager-body" key={retryKey}>
      <Worker workerUrl={PDF_WORKER_URL}>
        <Viewer
          fileUrl={fileUrl}
          plugins={[
            newPlugin,
            pageNavigationPluginInstance,
            highlightPluginInstance,
          ]}
          renderError={renderError}
        />
      </Worker>
    </div>
  );
}
```

[frontend/src/components/custom-tools/pdf-viewer/PdfViewer.jsx](https://github.com/Zipstack/unstract/blob/0cf6b9871675c43fb3f2353e1f3d56dcc07a48fa/frontend/src/components/custom-tools/pdf-viewer/PdfViewer.jsx#L50-L194) · [More projects using @react-pdf-viewer/core →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20React%20application%20projects%20using%20%40react-pdf-viewer/core%20for%20PDF%20page%20rendering%2C%20viewing%2C%20page%20navigation%2C%20text%20selection%20and%20document%20errors&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```jsx
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>;
}

```

From [App.tsx](https://react-pdf-viewer.dev/docs/basic-usage/)

### ng2-pdf-viewer

[GitHub](https://github.com/VadimDez/ng2-pdf-viewer) · [npm](https://www.npmjs.com/package/ng2-pdf-viewer) · [Docs](https://github.com/VadimDez/ng2-pdf-viewer#readme)

Renders PDFs as an Angular component.

- Downloads / mo: 1.6M
- Stars: 1.4K
- Last release: 10.4.0
- License: MIT
- Capabilities: [From the ng2-pdf-viewer docs](https://github.com/VadimDez/ng2-pdf-viewer#readme)

```sh
npm install ng2-pdf-viewer
```

**Quickstart**

```typescript
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'; }

```

From [README.md](https://github.com/VadimDez/ng2-pdf-viewer/blob/master/README.md) · [Find projects using ng2-pdf-viewer →](https://dashboard.exa.ai/playground/search?q=ng2-pdf-viewer%20GitHub%20projects)

### ngx-extended-pdf-viewer

[GitHub](https://github.com/stephanrauh/ngx-extended-pdf-viewer) · [npm](https://www.npmjs.com/package/ngx-extended-pdf-viewer) · [Docs](https://pdfviewer.net)

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
- Capabilities: [From the ngx-extended-pdf-viewer docs](https://pdfviewer.net)

```sh
ng add ngx-extended-pdf-viewer@32.0.2
```

**Quickstart**

```typescript
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 {}

```

From [README.md](https://www.npmjs.com/package/ngx-extended-pdf-viewer) · [Find projects using ngx-extended-pdf-viewer →](https://dashboard.exa.ai/playground/search?q=ngx-extended-pdf-viewer%20GitHub%20projects)

### @embedpdf/snippet

[GitHub](https://github.com/embedpdf/embed-pdf-viewer) · [npm](https://www.npmjs.com/package/@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
- Capabilities: [From the @embedpdf/snippet docs](https://www.npmjs.com/package/@embedpdf/snippet)

```sh
npm install @embedpdf/snippet
```

**grimmory-tools/grimmory** (4.7K stars)

[grimmory-tools/grimmory](https://github.com/grimmory-tools/grimmory) 

```javascript
searchAllPages(keyword: string): void {
    if (!this.search) return;
    const docId = this.currentDocumentId || undefined;
    const task = this.search.searchAllPages(keyword, docId);
    // After search completes, scroll to the first result
    task.wait(() => {
      this.scrollToActiveSearchResult();
    }, () => { /* search failed or cancelled */ });
  }
```

[frontend/src/app/features/readers/pdf-reader/services/embedpdf-book.service.ts](https://github.com/grimmory-tools/grimmory/blob/4f0ae626c9fba9dcbc925fd2bb53c262fcecec5f/frontend/src/app/features/readers/pdf-reader/services/embedpdf-book.service.ts#L328-L336) · [More projects using @embedpdf/snippet →](https://dashboard.exa.ai/playground/search?q=%40embedpdf/snippet%20GitHub%20projects)

**Quickstart**

```javascript
<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>

```

From [README.md](https://registry.npmjs.org/@embedpdf/snippet/2.15.1)

### vue-pdf-embed

[GitHub](https://github.com/hrynko/vue-pdf-embed) · [npm](https://www.npmjs.com/package/vue-pdf-embed) · [Docs](https://github.com/hrynko/vue-pdf-embed#readme)

Embeds PDFs as a Vue component.

- Downloads / mo: 998.7K
- Stars: 1.0K
- Last release: 2.1.7
- License: MIT
- Capabilities: [From the vue-pdf-embed docs](https://github.com/hrynko/vue-pdf-embed#readme)

```sh
npm install vue-pdf-embed vue@^3.3.0
```

**Quickstart**

```javascript
<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>

```

From [README.md](https://github.com/hrynko/vue-pdf-embed/blob/master/README.md) · [Find projects using vue-pdf-embed →](https://dashboard.exa.ai/playground/search?q=vue-pdf-embed%20GitHub%20projects)

## FAQ

### Which JavaScript PDF viewer library should I use?

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

### What is pdfjs-dist?

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

### What is the best React PDF viewer?

[React-PDF](#react-pdf) displays PDF documents and pages as React components. [React PDF Viewer](#react-pdf-viewer) adds an optional toolbar and other features through plugins.

### How do I show a PDF in Angular?

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

### What is Apryse WebViewer?

[Apryse WebViewer](#pdftron-webviewer) is a commercial JavaScript document SDK with a UI component library. It ships a full viewer toolbar and annotation tools.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript PDF viewer libraries PDF.js React-PDF PDFObject React PDF Viewer code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
