PACKAGE · PDF

pdfjs-dist

Generic build of Mozilla's PDF.js library.

WEEKLY DOWNLOADS 61.6M
STARS 54.2K
FORKS 10.7K
OPEN ISSUES 466
GZIP SIZE 132.6 kB
UNPACKED SIZE 37.6 MB
DEPENDENCIES 0
LAST UPDATED 8mo ago
DOWNLOAD TRENDS

pdfjs-dist downloads · last 12 months

Download trends for pdfjs-dist1 download series from Nov 2025 to Oct 2026. Use left and right arrow keys to inspect monthly values.041.6M83.2M124.9M166.5MNov 2025FebMayAugOct 2026
pdfjs-dist
ABOUT PDFJS-DIST

pdfjs-dist is the generic npm build of Mozilla’s PDF.js library. It lets web applications load PDF documents and render their pages for viewing, addressing the need to display PDF content inside an application rather than sending users to a separate reader.

PDF.js is designed for in-browser PDF viewing, with pdfjs-dist providing the distribution developers install and integrate. Its audience includes teams building document viewers, previews, and other interfaces where users need to inspect PDF pages as part of a web workflow.

The main workflow uses the `pdfjsLib.getDocument()` API to load a document, then retrieves pages and renders them through the page and rendering APIs. Applications commonly place rendered pages in canvas elements and connect viewer controls to document state, page navigation, and loading progress; the package also includes a worker-based architecture that should be configured appropriately for the application’s build and deployment setup.

The package can be integrated into plain JavaScript applications or used behind framework components that manage document loading and page rendering. It fits workflows that need an embedded PDF viewer, such as document previews or application-specific reading interfaces, while leaving interface design and viewer controls to the host application unless a separate viewer layer is used.

The supplied figures report 34.4 million weekly downloads, 54.1K GitHub stars, 10.7K forks, and 470 open issues, indicating a substantial project with ongoing issue tracking. The package’s reported unpacked size is 37.6 MB and its gzip bundle size is 132.6 kB, so developers should distinguish installed package contents from the compressed size figure when planning delivery.

Rendering PDFs in the browser requires handling asynchronous document loading, page rendering, worker configuration, and the resource costs of displaying pages. The generic build is not a finished application UI, so teams should plan their own viewer controls, error states, accessibility, and document security requirements; verify the chosen version’s browser and build compatibility before deployment.

WHEN TO USE
  • Embed PDF viewing in a web application by loading documents with `pdfjsLib.getDocument()` and rendering retrieved pages.
  • Build a page-by-page reader that renders PDF pages into canvas elements and provides application-specific navigation controls.
  • Create document previews where users need to inspect PDF content without leaving the current workflow.
  • Integrate PDF rendering into a framework component that manages asynchronous loading, page state, and rendering lifecycle.
  • Use the worker-based rendering architecture when configuring PDF processing for your application’s build and deployment environment.
  • Provide an application-specific reading interface while using PDF.js for document loading and page rendering rather than implementing PDF parsing yourself.
WHEN NOT TO USE
  • If users only need to download or open a PDF in their existing reader, link to the document or use the browser’s native PDF handling instead of rendering pages with `getDocument()`.
  • If you need a complete, ready-made viewer interface, use a viewer solution that supplies controls and navigation; pdfjs-dist is the generic library build, not a finished application UI.
  • If your application only needs to show text extracted from documents, choose a text-extraction workflow rather than rendering every page into canvas elements.
  • If your target environment cannot support the required browser rendering and worker setup, use a server-side document workflow or provide downloadable PDFs instead.
  • If the 37.6 MB unpacked package footprint is unsuitable for your installation constraints, evaluate a lighter PDF-rendering approach before adopting the generic build.
  • If you cannot manage asynchronous loading, rendering errors, and page lifecycle in your interface, choose an approach that provides those viewer behaviors out of the box.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 4
pdfjs-dist vs jspdf ★ 31.3K · 21.2M/wk pdfjs-dist vs puppeteer ★ 95.9K · 15.7M/wk pdfjs-dist vs pdfkit ★ 10.7K · 19.1M/wk pdfjs-dist vs @react-pdf/renderer ★ 16.9K · 10.0M/wk