Skip to content

Commit 13cf9ab

Browse files
committed
Merge upstream
2 parents 7479627 + cd3ab60 commit 13cf9ab

28 files changed

+704
-363
lines changed

Makefile

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
REPO = git@github.com:andreasgal/pdf.js.git
1+
REPO = git@github.com:mozilla/pdf.js.git
22
BUILD_DIR := build
33
BUILD_TARGET := $(BUILD_DIR)/pdf.js
44
DEFAULT_BROWSERS := resources/browser_manifests/browser_manifest.json
@@ -139,12 +139,11 @@ lint:
139139
# TODO: Use the Closure compiler to optimize the pdf.js files.
140140
#
141141
GH_PAGES = $(BUILD_DIR)/gh-pages
142-
web: | production extension compiler pages-repo \
143-
$(addprefix $(GH_PAGES)/, $(BUILD_TARGET)) \
144-
$(addprefix $(GH_PAGES)/, $(wildcard web/*.*)) \
145-
$(addprefix $(GH_PAGES)/, $(wildcard web/images/*.*)) \
146-
$(addprefix $(GH_PAGES)/, $(wildcard $(EXTENSION_SRC)/*.xpi))
147-
142+
web: | production extension compiler pages-repo
143+
@cp $(BUILD_TARGET) $(GH_PAGES)/$(BUILD_TARGET)
144+
@cp -R web/* $(GH_PAGES)/web
145+
@cp web/images/* $(GH_PAGES)/web/images
146+
@cp $(EXTENSION_SRC)/*.xpi $(GH_PAGES)/$(EXTENSION_SRC)
148147
@cp $(GH_PAGES)/web/index.html.template $(GH_PAGES)/index.html;
149148
@mv -f $(GH_PAGES)/web/viewer-production.html $(GH_PAGES)/web/viewer.html;
150149
@cd $(GH_PAGES); git add -A;
@@ -169,18 +168,6 @@ pages-repo: | $(BUILD_DIR)
169168
@mkdir -p $(GH_PAGES)/build;
170169
@mkdir -p $(GH_PAGES)/$(EXTENSION_SRC);
171170

172-
$(GH_PAGES)/$(BUILD_DIR)/%.js: build/%.js
173-
@cp $< $@
174-
175-
$(GH_PAGES)/web/%: web/%
176-
@cp $< $@
177-
178-
$(GH_PAGES)/web/images/%: web/images/%
179-
@cp $< $@
180-
181-
$(GH_PAGES)/$(EXTENSION_SRC)/%: $(EXTENSION_SRC)/%
182-
@cp -R $< $@
183-
184171
# # make compiler
185172
# #
186173
# # This target downloads the Closure compiler, and places it in the

README.md

Lines changed: 195 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,195 @@
1-
pdf.js has moved to: https://github.com/mozilla/pdf.js
1+
# pdf.js
2+
3+
4+
5+
## Overview
6+
7+
pdf.js is an HTML5 technology experiment that explores building a faithful
8+
and efficient Portable Document Format (PDF) renderer without native code
9+
assistance.
10+
11+
pdf.js is community-driven and supported by Mozilla Labs. Our goal is to
12+
create a general-purpose, web standards-based platform for parsing and
13+
rendering PDFs, and eventually release a PDF reader extension powered by
14+
pdf.js. Integration with Firefox is a possibility if the experiment proves
15+
successful.
16+
17+
18+
19+
## Getting started
20+
21+
### Online demo
22+
23+
For an online demo, visit:
24+
25+
+ http://mozilla.github.com/pdf.js/web/viewer.html
26+
27+
This demo provides an interactive interface for displaying and browsing PDFs
28+
using the pdf.js API.
29+
30+
### Extension
31+
32+
A Firefox extension is also available:
33+
34+
+ http://mozilla.github.com/pdf.js/extensions/firefox/pdf.js.xpi
35+
36+
However, note that the extension might not reflect the latest source in our master branch.
37+
38+
### Getting the code
39+
40+
To get a local copy of the current code, clone it using git:
41+
42+
$ git clone git://github.com/mozilla/pdf.js.git pdfjs
43+
$ cd pdfjs
44+
45+
Next, you need to start a local web server as some browsers don't allow opening
46+
PDF files for a file:// url:
47+
48+
$ make server
49+
50+
If everything worked out, you can now serve
51+
52+
+ http://localhost:8888/web/viewer.html
53+
54+
You can also view all the test pdf files on the right side serving
55+
56+
+ http://localhost:8888/test/pdfs/?frame
57+
58+
### Building pdf.js
59+
60+
In order to bundle all `src/` files into a final `pdf.js`, issue:
61+
62+
$ make
63+
64+
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).
65+
66+
67+
## Learning
68+
69+
Here are some initial pointers to help contributors get off the ground.
70+
Additional resources are available in a separate section below.
71+
72+
#### Hello world
73+
74+
For a "hello world" example, take a look at:
75+
76+
+ [examples/helloworld/hello.js](https://github.com/mozilla/pdf.js/blob/master/examples/helloworld/hello.js)
77+
78+
This example illustrates the bare minimum ingredients for integrating pdf.js
79+
in a custom project.
80+
81+
#### Introductory video
82+
83+
Check out the presentation by our contributor Julian Viereck on the inner
84+
workings of PDF and pdf.js:
85+
86+
+ http://www.youtube.com/watch?v=Iv15UY-4Fg8
87+
88+
89+
90+
91+
## Contributing
92+
93+
pdf.js is a community-driven project, so contributors are always welcome.
94+
Simply fork our repo and contribute away. A great place to start is our
95+
[open issues](https://github.com/mozilla/pdf.js/issues). For better consistency and
96+
long-term stability, please do look around the code and try to follow our conventions.
97+
More information about the contributor process can be found on the
98+
[contributor wiki page](https://github.com/mozilla/pdf.js/wiki/Contributing).
99+
100+
If you don't want to hack on the project or have little spare time, __you still
101+
can help!__ Just open PDFs in the
102+
[online demo](http://mozilla.github.com/pdf.js/web/viewer.html) and report
103+
any breakage in rendering.
104+
105+
Our Github contributors so far:
106+
107+
+ https://github.com/mozilla/pdf.js/contributors
108+
109+
You can add your name to it! :)
110+
111+
112+
113+
## Running the tests
114+
115+
pdf.js comes with browser-level regression tests that allow one to probe
116+
whether it's able to successfully parse PDFs, as well as compare its output
117+
against reference images, pixel-by-pixel.
118+
119+
To run the tests, first configure the browser manifest file at:
120+
121+
test/resources/browser_manifests/browser_manifest.json
122+
123+
Sample manifests for different platforms are provided in that directory.
124+
125+
To run all the bundled tests, type:
126+
127+
$ make test
128+
129+
and cross your fingers. Different types of tests are available, see the test
130+
manifest file at:
131+
132+
test/test_manifest.json
133+
134+
The test type `eq` tests whether the output images are identical to reference
135+
images. The test type `load` simply tests whether the file loads without
136+
raising any errors.
137+
138+
139+
## Running tests through our bot
140+
141+
If you are a reviewer, you can use our remote bot to issue comprehensive tests
142+
against reference images before merging pull requests.
143+
144+
See the bot repo for details:
145+
146+
+ https://github.com/mozilla/pdf.js-bot
147+
148+
149+
## Additional resources
150+
151+
Our demo site is here:
152+
153+
+ http://mozilla.github.com/pdf.js/web/viewer.html
154+
155+
You can read more about pdf.js here:
156+
157+
+ http://andreasgal.com/2011/06/15/pdf-js/
158+
+ http://blog.mozilla.com/cjones/2011/06/15/overview-of-pdf-js-guts/
159+
160+
Talk to us on IRC:
161+
162+
+ #pdfjs on irc.mozilla.org
163+
164+
Join our mailing list:
165+
166+
+ dev-pdf-js@lists.mozilla.org
167+
168+
Subscribe either using lists.mozilla.org or Google Groups:
169+
170+
+ https://lists.mozilla.org/listinfo/dev-pdf-js
171+
+ https://groups.google.com/group/mozilla.dev.pdf-js/topics
172+
173+
Follow us on twitter: @pdfjs
174+
175+
+ http://twitter.com/#!/pdfjs
176+
177+
178+
179+
## PDF-related resources
180+
181+
A really basic overview of PDF is described here:
182+
183+
+ http://partners.adobe.com/public/developer/en/livecycle/lc_pdf_overview_format.pdf
184+
185+
A more detailed file example:
186+
187+
+ http://gnupdf.org/Introduction_to_PDF
188+
189+
The PDF specification itself is an ISO and not freely available. However, there is
190+
a "PDF Reference" from Adobe:
191+
192+
+ http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_1-7.pdf
193+
194+
Recommended chapters to read: "2. Overview", "3.4 File Structure",
195+
"4.1 Graphics Objects" that lists the PDF commands.

examples/helloworld/index.html

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,33 @@
33

44
<head>
55
<!-- In production, only one script (pdf.js) is necessary -->
6-
<script type="text/javascript" src="../../src/core.js"></script>
7-
<script type="text/javascript" src="../../src/util.js"></script>
8-
<script type="text/javascript" src="../../src/canvas.js"></script>
9-
<script type="text/javascript" src="../../src/obj.js"></script>
10-
<script type="text/javascript" src="../../src/function.js"></script>
11-
<script type="text/javascript" src="../../src/charsets.js"></script>
12-
<script type="text/javascript" src="../../src/cidmaps.js"></script>
13-
<script type="text/javascript" src="../../src/colorspace.js"></script>
14-
<script type="text/javascript" src="../../src/crypto.js"></script>
15-
<script type="text/javascript" src="../../src/evaluator.js"></script>
16-
<script type="text/javascript" src="../../src/fonts.js"></script>
17-
<script type="text/javascript" src="../../src/glyphlist.js"></script>
18-
<script type="text/javascript" src="../../src/image.js"></script>
19-
<script type="text/javascript" src="../../src/metrics.js"></script>
20-
<script type="text/javascript" src="../../src/parser.js"></script>
21-
<script type="text/javascript" src="../../src/pattern.js"></script>
22-
<script type="text/javascript" src="../../src/stream.js"></script>
23-
<script type="text/javascript" src="../../src/worker.js"></script>
6+
<!-- In production, change the content of PDFJS.workerSrc below -->
7+
<script type="text/javascript" src="../../src/core.js"></script>
8+
<script type="text/javascript" src="../../src/util.js"></script>
9+
<script type="text/javascript" src="../../src/canvas.js"></script>
10+
<script type="text/javascript" src="../../src/obj.js"></script>
11+
<script type="text/javascript" src="../../src/function.js"></script>
12+
<script type="text/javascript" src="../../src/charsets.js"></script>
13+
<script type="text/javascript" src="../../src/cidmaps.js"></script>
14+
<script type="text/javascript" src="../../src/colorspace.js"></script>
15+
<script type="text/javascript" src="../../src/crypto.js"></script>
16+
<script type="text/javascript" src="../../src/evaluator.js"></script>
17+
<script type="text/javascript" src="../../src/fonts.js"></script>
18+
<script type="text/javascript" src="../../src/glyphlist.js"></script>
19+
<script type="text/javascript" src="../../src/image.js"></script>
20+
<script type="text/javascript" src="../../src/metrics.js"></script>
21+
<script type="text/javascript" src="../../src/parser.js"></script>
22+
<script type="text/javascript" src="../../src/pattern.js"></script>
23+
<script type="text/javascript" src="../../src/stream.js"></script>
24+
<script type="text/javascript" src="../../src/worker.js"></script>
2425

26+
<script type="text/javascript">
27+
// Specify the main script used to create a new PDF.JS web worker.
28+
// In production, change this to point to the combined `pdf.js` file.
29+
PDFJS.workerSrc = '../../src/worker_loader.js';
30+
</script>
2531
<script type="text/javascript" src="hello.js"></script>
26-
</head>
32+
</head>
2733

2834
<body>
2935
<canvas id="the-canvas" style="border:1px solid black;"/>

extensions/firefox/bootstrap.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,31 @@ function log(str) {
1616

1717
function startup(aData, aReason) {
1818
let manifestPath = 'chrome.manifest';
19-
let file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile);
19+
let manifest = Cc['@mozilla.org/file/local;1']
20+
.createInstance(Ci.nsILocalFile);
2021
try {
21-
file.initWithPath(aData.installPath.path);
22-
file.append(manifestPath);
23-
Cm.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(file);
22+
manifest.initWithPath(aData.installPath.path);
23+
manifest.append(manifestPath);
24+
Cm.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(manifest);
25+
Services.prefs.setBoolPref('extensions.pdf.js.active', true);
2426
} catch (e) {
2527
log(e);
2628
}
2729
}
2830

2931
function shutdown(aData, aReason) {
32+
if (Services.prefs.getBoolPref('extensions.pdf.js.active'))
33+
Services.prefs.setBoolPref('extensions.pdf.js.active', false);
3034
}
3135

3236
function install(aData, aReason) {
3337
let url = 'chrome://pdf.js/content/web/viewer.html?file=%s';
3438
Services.prefs.setCharPref('extensions.pdf.js.url', url);
39+
Services.prefs.setBoolPref('extensions.pdf.js.active', false);
40+
}
41+
42+
function uninstall(aData, aReason) {
43+
Services.prefs.clearUserPref('extensions.pdf.js.url');
44+
Services.prefs.clearUserPref('extensions.pdf.js.active');
3545
}
3646

extensions/firefox/components/pdfContentHandler.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ pdfContentHandler.prototype = {
3232
if (!(aRequest instanceof Ci.nsIChannel))
3333
throw NS_ERROR_WONT_HANDLE_CONTENT;
3434

35+
if (!Services.prefs.getBoolPref('extensions.pdf.js.active'))
36+
throw NS_ERROR_WONT_HANDLE_CONTENT;
37+
3538
let window = null;
3639
let callbacks = aRequest.notificationCallbacks ||
3740
aRequest.loadGroup.notificationCallbacks;
@@ -53,7 +56,7 @@ pdfContentHandler.prototype = {
5356
throw NS_ERROR_WONT_HANDLE_CONTENT;
5457

5558
aRequest.cancel(Cr.NS_BINDING_ABORTED);
56-
window.location = url.replace('%s', targetUrl);
59+
window.location = url.replace('%s', encodeURIComponent(targetUrl));
5760
},
5861

5962
classID: Components.ID('{2278dfd0-b75c-11e0-8257-1ba3d93c9f1a}'),

extensions/firefox/install.rdf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
<em:unpack>true</em:unpack>
2020
<em:creator>Vivien Nicolas</em:creator>
2121
<em:description>pdf.js uri loader</em:description>
22-
<em:homepageURL>https://github.com/andreasgal/pdf.js/</em:homepageURL>
22+
<em:homepageURL>https://github.com/mozilla/pdf.js/</em:homepageURL>
2323
</Description>
2424
</RDF>

0 commit comments

Comments
 (0)