PACKAGE · PDF

pdfjs-dist

Generic build of Mozilla's PDF.js library.

WEEKLY DOWNLOADS 8.9M
STARS 53.4K
FORKS 10.6K
OPEN ISSUES 423
GZIP SIZE 125.0 kB
UNPACKED SIZE 35.6 MB
DEPENDENCIES 0
LAST UPDATED 3mo ago
DOWNLOAD TRENDS

pdfjs-dist downloads — last 12 months

Download trends for pdfjs-dist1 download series from Jun 2025 to May 2026. Use left and right arrow keys to inspect monthly values.016.5M33.1M49.6M66.2MJun 2025SepDecMarMay 2026
pdfjs-dist
ABOUT PDFJS-DIST

pdfjs-dist is the generic build of Mozilla's PDF.js library, a powerful JavaScript framework designed for parsing and rendering PDF documents directly within web browsers. It empowers developers to display PDF content without relying on external plugins or server-side conversions, tackling the challenge of integrating dynamic PDF viewing into web applications.

Developed with a focus on accuracy and comprehensive PDF standard support, PDF.js aims to provide a reliable engine for rendering PDFs. Its primary audience includes frontend developers building applications that require embedding or interacting with PDF files, such as document management systems, online readers, or educational platforms.

The library's core functionality revolves around its ability to load a PDF document and then render its pages onto an HTML Canvas element. Developers interact with the API by obtaining a `PDFDocumentProxy` object, from which they can access page information and request individual pages to be rendered using methods like `page.render()`. This programmatic approach allows for fine-grained control over the display and interaction of PDF content.

pi-dist integrates seamlessly into various frontend JavaScript frameworks and build tools. Its modular nature allows for selective importing of components, making it adaptable to different project structures. It's commonly used with bundlers like Webpack or Rollup, and easily incorporated into React, Vue, or Angular applications through appropriate wrappers or direct API usage.

With a substantial weekly download count of 16.9 million, pdfjs-dist is a mature and widely adopted solution for client-side PDF rendering. Its unpacked size of 35.6 MB and a gzipped bundle size of 125.0 kB indicate a considerable feature set, though developers should consider this in their build optimization strategies.

While highly capable, developers should be aware of pdfjs-dist's reliance on the Canvas API for rendering, which might not be suitable for all accessibility needs or high-fidelity vector graphics requirements. Complex or malformed PDFs can also present rendering challenges, and performance may vary depending on the complexity of the PDF and the client device's capabilities.

WHEN TO USE
  • When rendering PDF documents within a web application without requiring server-side processing, leveraging the `pdfjs-dist` core rendering engine.
  • When providing interactive PDF viewing capabilities, such as page navigation, zoom, and text selection, by utilizing the page rendering and annotation APIs.
  • When integrating PDF previews for uploaded documents directly in the browser before submission, using `PDFDocumentProxy.getPage()` and `PageViewport.render()`.
  • When building custom PDF viewers or editors where programmatic access to page content and structure is necessary via the `getDocument()` and `page.getTextContent()` methods.
  • When targeting a broad range of modern web browsers that support the HTML Canvas API for rendering.
  • When needing to extract text or metadata from PDF files client-side, employing methods like `page.getTextContent()` or `PDFDocumentProxy.getMetadata()`.
WHEN NOT TO USE
  • If your sole requirement is to provide a static download link for a PDF file, as this package is designed for dynamic rendering.
  • If your application primarily deals with image formats and PDF rendering is an infrequent or non-critical feature, consider lighter-weight solutions.
  • If targeting extremely old browsers that lack robust HTML Canvas support, as `pdfjs-dist` fundamentally relies on this technology.
  • If you need to perform server-side PDF generation or modification, as `pdfjs-dist` is a client-side rendering library.
  • For applications where every kilobyte of JavaScript bundle size is critically optimized and PDF viewing is not a core feature, explore alternative PDF embedding methods or lighter libraries if available for specific, simpler tasks.

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.2K · 7.7M/wk pdfjs-dist vs puppeteer ★ 93.5K · 5.3M/wk pdfjs-dist vs pdfkit ★ 10.7K · 2.0M/wk pdfjs-dist vs @react-pdf/renderer ★ 16.6K · 1.9M/wk