2012-01-19 23:56:08 +09:00
|
|
|
# PDF.JS
|
2012-03-27 11:43:51 +09:00
|
|
|
|
2012-04-06 08:32:08 +09:00
|
|
|
|
2011-09-16 08:28:38 +09:00
|
|
|
pdf.js is an HTML5 technology experiment that explores building a faithful
|
|
|
|
and efficient Portable Document Format (PDF) renderer without native code
|
|
|
|
assistance.
|
|
|
|
|
|
|
|
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, and eventually release a PDF reader extension powered by
|
|
|
|
pdf.js. Integration with Firefox is a possibility if the experiment proves
|
|
|
|
successful.
|
|
|
|
|
2012-02-01 05:31:26 +09:00
|
|
|
|
2011-09-16 08:28:38 +09:00
|
|
|
|
2012-01-19 23:56:08 +09:00
|
|
|
# Getting started
|
2011-09-16 08:28:38 +09:00
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
### Online demo
|
2011-09-16 08:39:18 +09:00
|
|
|
|
2011-09-16 08:28:38 +09:00
|
|
|
For an online demo, visit:
|
|
|
|
|
2011-11-01 21:49:47 +09:00
|
|
|
+ http://mozilla.github.com/pdf.js/web/viewer.html
|
2011-09-16 08:28:38 +09:00
|
|
|
|
|
|
|
This demo provides an interactive interface for displaying and browsing PDFs
|
|
|
|
using the pdf.js API.
|
|
|
|
|
2011-10-25 02:40:36 +09:00
|
|
|
### Extension
|
|
|
|
|
2012-02-09 07:40:40 +09:00
|
|
|
A Firefox extension is availble in two places:
|
2011-10-25 02:40:36 +09:00
|
|
|
|
2012-02-09 07:40:40 +09:00
|
|
|
+ Stable Version: https://addons.mozilla.org/en-US/firefox/addon/pdfjs
|
|
|
|
+ Development Version: http://mozilla.github.com/pdf.js/extensions/firefox/pdf.js.xpi
|
2011-10-25 02:40:36 +09:00
|
|
|
|
2012-02-09 07:40:40 +09:00
|
|
|
The development extension should be quite stable but still might break from time to time.
|
|
|
|
Also, note that the development extension is updated on every merge and by default Firefox will
|
|
|
|
auto-update extensions on a daily basis (you can change this through the
|
|
|
|
`extensions.update.interval` option in `about:config`).
|
2011-11-08 00:42:12 +09:00
|
|
|
|
2012-04-26 00:02:02 +09:00
|
|
|
For an experimental Chrome extension, get the code as explained below and issue `node make extension`.
|
2012-02-14 19:47:03 +09:00
|
|
|
Then open Chrome, go to `Tools > Extension` and load the (unpackaged) extension
|
|
|
|
from the directory `build/chrome`.
|
2011-10-25 02:40:36 +09:00
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
### Getting the code
|
2011-09-25 18:44:29 +09:00
|
|
|
|
|
|
|
To get a local copy of the current code, clone it using git:
|
|
|
|
|
2011-11-01 21:46:39 +09:00
|
|
|
$ git clone git://github.com/mozilla/pdf.js.git pdfjs
|
2011-09-30 03:52:56 +09:00
|
|
|
$ cd pdfjs
|
2011-09-25 18:44:29 +09:00
|
|
|
|
|
|
|
Next, you need to start a local web server as some browsers don't allow opening
|
|
|
|
PDF files for a file:// url:
|
|
|
|
|
2012-04-26 00:02:02 +09:00
|
|
|
$ node make server
|
2011-09-25 18:44:29 +09:00
|
|
|
|
2012-04-26 00:02:02 +09:00
|
|
|
You can install Node via [nvm](https://github.com/creationix/nvm) or the
|
|
|
|
[official package](http://nodejs.org). If everything worked out, you can now serve
|
2011-09-25 18:44:29 +09:00
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
+ http://localhost:8888/web/viewer.html
|
2011-09-25 18:44:29 +09:00
|
|
|
|
|
|
|
You can also view all the test pdf files on the right side serving
|
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
+ http://localhost:8888/test/pdfs/?frame
|
2011-09-25 18:44:29 +09:00
|
|
|
|
2011-10-26 12:07:30 +09:00
|
|
|
### Building pdf.js
|
|
|
|
|
|
|
|
In order to bundle all `src/` files into a final `pdf.js`, issue:
|
|
|
|
|
2012-04-26 00:02:02 +09:00
|
|
|
$ node make bundle
|
2011-10-26 12:07:30 +09:00
|
|
|
|
|
|
|
This will generate the file `build/pdf.js` that can be included in your final project. (WARNING: That's a large file! Consider minifying it).
|
|
|
|
|
2011-10-27 00:20:22 +09:00
|
|
|
|
2012-01-19 23:56:08 +09:00
|
|
|
# Learning
|
2011-09-25 18:44:29 +09:00
|
|
|
|
2012-04-06 22:18:18 +09:00
|
|
|
You can play with the PDF.js API directly from your browser through the live demos below:
|
2011-09-25 18:44:29 +09:00
|
|
|
|
2012-04-06 22:18:18 +09:00
|
|
|
+ Hello world: http://jsbin.com/pdfjs-helloworld/edit#html,live
|
|
|
|
+ Simple reader with prev/next page controls: http://jsbin.com/pdfjs-prevnext/edit#html,live
|
2011-09-16 08:39:18 +09:00
|
|
|
|
2012-04-06 22:18:18 +09:00
|
|
|
The repo contains a hello world example that you can run locally:
|
2011-09-16 08:28:38 +09:00
|
|
|
|
2011-11-01 21:46:39 +09:00
|
|
|
+ [examples/helloworld/hello.js](https://github.com/mozilla/pdf.js/blob/master/examples/helloworld/hello.js)
|
2011-09-16 08:28:38 +09:00
|
|
|
|
2012-04-06 22:18:18 +09:00
|
|
|
For an introduction to the PDF.js code, check out the presentation by our contributor Julian Viereck:
|
2011-10-27 00:20:22 +09:00
|
|
|
|
|
|
|
+ http://www.youtube.com/watch?v=Iv15UY-4Fg8
|
|
|
|
|
|
|
|
|
2011-09-16 08:28:38 +09:00
|
|
|
|
|
|
|
|
2012-01-19 23:56:08 +09:00
|
|
|
# Contributing
|
2011-09-25 18:48:12 +09:00
|
|
|
|
2011-09-30 03:49:36 +09:00
|
|
|
pdf.js is a community-driven project, so contributors are always welcome.
|
2011-11-17 05:27:28 +09:00
|
|
|
Simply fork our repo and contribute away. Good starting places for picking
|
|
|
|
a bug are the top error messages and TODOs in our corpus report:
|
|
|
|
|
|
|
|
+ http://people.mozilla.com/~bdahl/corpusreport/test/ref/
|
|
|
|
|
|
|
|
and of course our open Github issues:
|
|
|
|
|
|
|
|
+ https://github.com/mozilla/pdf.js/issues
|
|
|
|
|
|
|
|
For better consistency and long-term stability, please do look around the
|
|
|
|
code and try to follow our conventions.
|
2011-10-08 03:49:57 +09:00
|
|
|
More information about the contributor process can be found on the
|
2011-11-01 21:46:39 +09:00
|
|
|
[contributor wiki page](https://github.com/mozilla/pdf.js/wiki/Contributing).
|
2011-09-25 18:48:12 +09:00
|
|
|
|
2011-10-08 03:47:17 +09:00
|
|
|
If you don't want to hack on the project or have little spare time, __you still
|
2011-09-30 03:44:41 +09:00
|
|
|
can help!__ Just open PDFs in the
|
2011-11-01 21:49:47 +09:00
|
|
|
[online demo](http://mozilla.github.com/pdf.js/web/viewer.html) and report
|
2011-09-25 18:48:12 +09:00
|
|
|
any breakage in rendering.
|
|
|
|
|
2011-09-30 03:49:36 +09:00
|
|
|
Our Github contributors so far:
|
|
|
|
|
2011-11-01 21:46:39 +09:00
|
|
|
+ https://github.com/mozilla/pdf.js/contributors
|
2011-09-30 03:49:36 +09:00
|
|
|
|
|
|
|
You can add your name to it! :)
|
|
|
|
|
2011-09-25 18:48:12 +09:00
|
|
|
|
2012-01-19 23:56:08 +09:00
|
|
|
# Running the tests
|
2011-09-16 08:28:38 +09:00
|
|
|
|
2012-03-13 02:55:31 +09:00
|
|
|
pdf.js comes with browser-level regression tests that allow one to probe
|
2011-09-16 08:28:38 +09:00
|
|
|
whether it's able to successfully parse PDFs, as well as compare its output
|
|
|
|
against reference images, pixel-by-pixel.
|
|
|
|
|
2012-03-13 02:55:31 +09:00
|
|
|
More information about running the tests can be found on the
|
|
|
|
[contributor wiki page](https://github.com/mozilla/pdf.js/wiki/Contributing).
|
2011-10-05 00:27:40 +09:00
|
|
|
|
|
|
|
|
2012-01-19 23:56:08 +09:00
|
|
|
# Additional resources
|
2011-06-29 17:00:16 +09:00
|
|
|
|
2011-11-17 03:54:36 +09:00
|
|
|
Gallery of user projects and modifications:
|
2011-07-03 01:30:46 +09:00
|
|
|
|
2011-11-17 03:54:36 +09:00
|
|
|
+ https://github.com/mozilla/pdf.js/wiki/Gallery-of-user-projects-and-modifications
|
2011-07-03 01:30:46 +09:00
|
|
|
|
2011-06-17 01:37:15 +09:00
|
|
|
You can read more about pdf.js here:
|
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
+ http://andreasgal.com/2011/06/15/pdf-js/
|
|
|
|
+ http://blog.mozilla.com/cjones/2011/06/15/overview-of-pdf-js-guts/
|
2011-07-03 01:28:13 +09:00
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
Talk to us on IRC:
|
2011-06-17 01:37:15 +09:00
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
+ #pdfjs on irc.mozilla.org
|
2011-06-29 08:02:02 +09:00
|
|
|
|
2011-09-20 03:11:14 +09:00
|
|
|
Join our mailing list:
|
2011-06-29 08:02:02 +09:00
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
+ dev-pdf-js@lists.mozilla.org
|
|
|
|
|
2011-09-20 03:11:14 +09:00
|
|
|
Subscribe either using lists.mozilla.org or Google Groups:
|
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
+ https://lists.mozilla.org/listinfo/dev-pdf-js
|
|
|
|
+ https://groups.google.com/group/mozilla.dev.pdf-js/topics
|
2011-06-29 08:02:02 +09:00
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
Follow us on twitter: @pdfjs
|
2011-06-29 08:02:02 +09:00
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
+ http://twitter.com/#!/pdfjs
|
|
|
|
|
|
|
|
|
2011-09-25 19:04:35 +09:00
|
|
|
|
2012-01-19 23:56:08 +09:00
|
|
|
### PDF-related resources
|
2011-09-25 19:04:35 +09:00
|
|
|
|
|
|
|
A really basic overview of PDF is described here:
|
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
+ http://partners.adobe.com/public/developer/en/livecycle/lc_pdf_overview_format.pdf
|
2011-09-25 19:04:35 +09:00
|
|
|
|
|
|
|
A more detailed file example:
|
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
+ http://gnupdf.org/Introduction_to_PDF
|
2011-09-25 19:04:35 +09:00
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
The PDF specification itself is an ISO and not freely available. However, there is
|
2011-09-25 19:04:35 +09:00
|
|
|
a "PDF Reference" from Adobe:
|
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
+ http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_1-7.pdf
|
2011-09-25 19:04:35 +09:00
|
|
|
|
2011-09-30 03:44:41 +09:00
|
|
|
Recommended chapters to read: "2. Overview", "3.4 File Structure",
|
2011-09-25 19:04:35 +09:00
|
|
|
"4.1 Graphics Objects" that lists the PDF commands.
|