Skip to content

ZigaoWang/pdf.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF.js Build Status

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.

Table of Contents

Contributing

PDF.js thrives on community contributions! If you're interested in getting involved, check out the following resources:

Join our Matrix room for questions or support!

Getting Started

Online Demo

To explore PDF.js functionality, visit:

Browser Extensions

  • 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 the build/chromium directory in Chrome.

Getting the Code

To clone the repository:

$ git clone https://github.com/mozilla/pdf.js.git
$ cd pdf.js

Install Node.js from the official site or via nvm. Then, install dependencies:

$ npm install

Note

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 server

Access the viewer at:

You can also view test PDFs here:

Building PDF.js

To bundle source files and build the generic viewer, run:

$ npx gulp generic

For older browser support, run:

$ npx gulp generic-legacy

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

Using PDF.js in a Web Application

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.

Including via a CDN

PDF.js is available on several CDNs:

Learning Resources

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-install

For 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:

Questions?

Check our FAQs for common inquiries, join the discussion on Matrix, or file an issue here.

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 73.3%
  • Fluent 24.0%
  • CSS 1.8%
  • Other 0.9%