Skip to content
PDF Reader in JavaScript
JavaScript CSS HTML
Branch: master
Clone or download
timvandermeij Merge pull request #11335 from Snuffleupagus/issue-11330
Subtract `stream.start` when getting the `startXRef` property for documents with a Linearization dictionary (issue 11330)
Latest commit be02e67 Nov 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Attempt to clarify the `l10n` section of `CONTRIBUTING.md` Apr 10, 2019
docs Fix the link in the doc website Sep 19, 2019
examples Add Create React App example with TypeScript and basic usage Oct 10, 2019
extensions [Firefox] Stop fetching the `chrome.properties` files during `gulp im… Oct 17, 2019
external Simplify the handling of `EXCLUDE_LANG_CODES` (PR 11213 follow-up) Oct 26, 2019
l10n Update l10n files Oct 26, 2019
src Merge pull request #11335 from Snuffleupagus/issue-11330 Nov 16, 2019
test Subtract `stream.start` when getting the `startXRef` property for doc… Nov 16, 2019
web [PDFHistory] Move the IE11 `pushState`/`replaceState` work-around to … Nov 11, 2019
.editorconfig Uses editorconfig to maintain consistent coding styles Nov 14, 2015
.eslintignore Replace the bundled `ReadableStream` polyfill with the `web-streams-p… Sep 23, 2019
.eslintrc [MessageHandler] Convert all instances of `var` to `const` in the code Oct 30, 2019
.gitattributes Fixing C++,PHP and Pascal presence in the repo Oct 29, 2015
.gitignore Include `package-lock.json` for reproducible builds Jun 2, 2018
.gitmodules Update fonttools location and version (issue 6223) Jul 17, 2015
.gitpod.Dockerfile Simplifies code contributions by automating the dev setup with gitpod.io Nov 6, 2019
.gitpod.yml Simplifies code contributions by automating the dev setup with gitpod.io Nov 6, 2019
.mailmap Add mgol's name to AUTHORS, add .mailmap Nov 22, 2017
.travis.yml Upgrade to Gulp 4 Dec 17, 2018
AUTHORS Add SehyunPark to AUTHORS Nov 29, 2017
CODE_OF_CONDUCT.md Add Mozilla Code of Conduct file Mar 28, 2019
EXPORT Adds ECCN response statement Oct 23, 2017
LICENSE cleaned whitespace Feb 17, 2015
README.md Simplifies code contributions by automating the dev setup with gitpod.io Nov 6, 2019
gulpfile.js fix nodejs core module : in web browser ignore url module Nov 4, 2019
package-lock.json Fix (some) vulnerabilities reported by `npm audit` Nov 11, 2019
package.json Update npm packages Nov 11, 2019
pdfjs.config Bump versions in `pdfjs.config` Oct 3, 2019
systemjs.config.js Replace the bundled `ReadableStream` polyfill with the `web-streams-p… Sep 23, 2019

README.md

PDF.js Build Status

PDF.js is a Portable Document Format (PDF) viewer that is built with HTML5.

PDF.js is community-driven and supported by Mozilla Labs. Our goal is to create a general-purpose, web standards-based platform for parsing and rendering PDFs.

Contributing

PDF.js is an open source project and always looking for more contributors. To get involved, visit:

Feel free to stop by #pdfjs on irc.mozilla.org for questions or guidance.

Getting Started

Online demo

Browser Extensions

Firefox

PDF.js is built into version 19+ of Firefox.

Chrome

  • The official extension for Chrome can be installed from the Chrome Web Store. This extension is maintained by @Rob--W.
  • Build Your Own - Get the code as explained below and issue gulp chromium. Then open Chrome, go to Tools > Extension and load the (unpackaged) extension from the directory build/chromium.

Getting the Code

To get a local copy of the current code, clone it using git:

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

Next, install Node.js via the official package or via nvm. You need to install the gulp package globally (see also gulp's getting started):

$ npm install -g gulp-cli

If everything worked out, install all dependencies for PDF.js:

$ npm install

Finally, you need to start a local web server as some browsers do not allow opening PDF files using a file:// URL. Run:

$ gulp server

and then you can open:

Please keep in mind that this requires an ES6 compatible browser; refer to Building PDF.js for usage with older browsers.

It is also possible to view all test PDF files on the right side by opening:

Online setup with a single click

It's recommended to follow [Getting the Code] above, however you can also use Gitpod (a free online VS Code like IDE). With a single click it will launch a ready to use workspace, with all the dependencies pre-installed and the web server running, so that you can start coding straight away.

Open in Gitpod

Building PDF.js

In order to bundle all src/ files into two production scripts and build the generic viewer, run:

$ gulp generic

This will generate pdf.js and pdf.worker.js in the build/generic/build/ directory. Both scripts are needed but only pdf.js needs to be included since pdf.worker.js will be loaded by pdf.js. The PDF.js files are large and should be minified for production.

Using PDF.js in a web application

To use PDF.js in a web application you can choose to use a pre-built version of the library or to build it from source. We supply pre-built versions for usage with NPM and Bower under the pdfjs-dist name. For more information and examples please refer to the wiki page on this subject.

Including via a CDN

PDF.js is hosted on several free CDNs:

Learning

You can play with the PDF.js API directly from your browser using the live demos below:

More examples can be found in the examples folder. Some of them are using the pdfjs-dist package, which can be built and installed in this repo directory via gulp dist-install command.

For an introduction to the PDF.js code, check out the presentation by our contributor Julian Viereck:

More learning resources can be found at:

The API documentation can be found at:

Questions

Check out our FAQs and get answers to common questions:

Talk to us on IRC (Internet Relay Chat):

  • #pdfjs on irc.mozilla.org

File an issue:

Follow us on twitter: @pdfjs

You can’t perform that action at this time.