PDF.js is a powerful HTML5-based PDF viewer developed by Mozilla. Our mission is to provide a robust, web standards-based platform for parsing and rendering PDF documents. It is community-driven and supported by Mozilla.
- Contributing
- Getting Started
- Building PDF.js
- Using PDF.js in a Web Application
- Including via a CDN
- Learning Resources
- Questions
PDF.js thrives on community contributions! If you're interested in getting involved, check out the following resources:
- Issue Reporting Guide
- Code Contribution Guide
- Frequently Asked Questions
- Good Beginner Bugs
- Projects
Join our Matrix room for questions or support!
To explore PDF.js functionality, visit:
- Modern Browsers: Demo
- Older Browsers: Legacy Demo
- Firefox: Integrated into Firefox 19 and above.
- Chrome:
- Install the official extension from the Chrome Web Store (maintained by @Rob--W).
- Build Your Own: Clone the repo and run
npx gulp chromium. Load the unpacked extension from thebuild/chromiumdirectory in Chrome.
To clone the repository:
$ git clone https://github.com/mozilla/pdf.js.git
$ cd pdf.jsInstall Node.js from the official site or via nvm. Then, install dependencies:
$ npm installNote
On macOS with Apple Silicon (M1, M2, M3, etc.), you may face node-gyp-related errors during npm install. Ensure you have the necessary native dependencies for canvas installed via Homebrew. For instructions, visit node-canvas Compilation.
Start a local web server:
$ npx gulp serverAccess the viewer at:
You can also view test PDFs here:
To bundle source files and build the generic viewer, run:
$ npx gulp genericFor older browser support, run:
$ npx gulp generic-legacyGenerated files will be located in the build/generic/build/ and build/generic-legacy/build/ directories. Include pdf.js in your project; pdf.worker.js will load automatically.
You can integrate PDF.js into your web application using a pre-built version or by building from source. Pre-built versions are available as pdfjs-dist. More details and examples can be found in our setup guide.
PDF.js is available on several CDNs:
Experiment with the PDF.js API through live demos:
Additional examples are available in the examples folder. To build and install the pdfjs-dist package, use:
$ npx gulp dist-installFor an introduction to PDF.js code, check out this presentation by contributor Julian Viereck: Watch Presentation.
More learning resources can be found at:
API documentation is available at:
Check our FAQs for common inquiries, join the discussion on Matrix, or file an issue here.