Skip to content

Commit 97ebd26

Browse files
committed
Merge with upstream
2 parents 3fb3a39 + cd3ab60 commit 97ebd26

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+8360
-7963
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ pdf.pdf
33
intelisa.pdf
44
openweb_tm-PRINT.pdf
55
local.mk
6+
build/
7+

Makefile

Lines changed: 71 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
1-
REPO = git@github.com:andreasgal/pdf.js.git
1+
REPO = git@github.com:mozilla/pdf.js.git
22
BUILD_DIR := build
3+
BUILD_TARGET := $(BUILD_DIR)/pdf.js
34
DEFAULT_BROWSERS := resources/browser_manifests/browser_manifest.json
45
DEFAULT_TESTS := test_manifest.json
56

67
EXTENSION_SRC := ./extensions/
78
FIREFOX_EXTENSION_NAME := pdf.js.xpi
89
CHROME_EXTENSION_NAME := pdf.js.crx
910

11+
all: bundle
12+
1013
# Let folks define custom rules for their clones.
1114
-include local.mk
1215

1316
# JS files needed for pdf.js.
14-
# This list doesn't account for the 'worker' directory.
1517
PDF_JS_FILES = \
16-
pdf.js \
17-
crypto.js \
18-
fonts.js \
19-
metrics.js \
20-
charsets.js \
21-
cidmaps.js \
22-
glyphlist.js \
18+
core.js \
19+
util.js \
20+
canvas.js \
21+
obj.js \
22+
function.js \
23+
charsets.js \
24+
cidmaps.js \
25+
colorspace.js \
26+
crypto.js \
27+
evaluator.js \
28+
fonts.js \
29+
glyphlist.js \
30+
image.js \
31+
metrics.js \
32+
parser.js \
33+
pattern.js \
34+
stream.js \
35+
worker.js \
2336
$(NULL)
2437

25-
# not sure what to do for all yet
26-
all: help
27-
2838
# make server
2939
#
3040
# This target starts a local web server at localhost:8888. This can be
@@ -34,6 +44,28 @@ server:
3444

3545
test: shell-test browser-test
3646

47+
#
48+
# Create production output (pdf.js, and corresponding changes to web files)
49+
#
50+
production: | bundle
51+
@echo "Preparing web/viewer-production.html"; \
52+
cd web; \
53+
sed '/PDFJSSCRIPT_REMOVE/d' viewer.html > viewer-1.tmp; \
54+
sed '/PDFJSSCRIPT_INCLUDE_BUILD/ r viewer-snippet.html' viewer-1.tmp > viewer-production.html; \
55+
rm -f *.tmp; \
56+
cd ..
57+
58+
#
59+
# Bundle pdf.js
60+
#
61+
bundle: | $(BUILD_DIR)
62+
@echo "Bundling source files into $(BUILD_TARGET)"
63+
@cd src; \
64+
cat $(PDF_JS_FILES) > all_files.tmp; \
65+
sed '/PDFJSSCRIPT_INCLUDE_ALL/ r all_files.tmp' pdf.js > ../$(BUILD_TARGET); \
66+
rm -f *.tmp; \
67+
cd ..
68+
3769
# make browser-test
3870
#
3971
# This target runs in-browser tests using two primary arguments: a
@@ -93,11 +125,11 @@ browser-test:
93125
# To install gjslint, see:
94126
#
95127
# <http://code.google.com/closure/utilities/docs/linter_howto.html>
96-
SRC_DIRS := . utils worker web test examples/helloworld extensions/firefox \
128+
SRC_DIRS := . src utils web test examples/helloworld extensions/firefox \
97129
extensions/firefox/components extensions/chrome
98130
GJSLINT_FILES = $(foreach DIR,$(SRC_DIRS),$(wildcard $(DIR)/*.js))
99131
lint:
100-
gjslint $(GJSLINT_FILES)
132+
gjslint --nojsdoc $(GJSLINT_FILES)
101133

102134
# make web
103135
#
@@ -108,14 +140,13 @@ lint:
108140
# TODO: Use the Closure compiler to optimize the pdf.js files.
109141
#
110142
GH_PAGES = $(BUILD_DIR)/gh-pages
111-
web: | extension compiler pages-repo \
112-
$(addprefix $(GH_PAGES)/, $(PDF_JS_FILES)) \
113-
$(addprefix $(GH_PAGES)/, $(wildcard web/*.*)) \
114-
$(addprefix $(GH_PAGES)/, $(wildcard web/images/*.*)) \
115-
$(addprefix $(GH_PAGES)/, $(wildcard $(EXTENSION_SRC)/firefox/*.xpi)) \
116-
$(addprefix $(GH_PAGES)/, $(wildcard $(EXTENSION_SRC)/chrome/*.crx))
117-
143+
web: | production extension compiler pages-repo
144+
@cp $(BUILD_TARGET) $(GH_PAGES)/$(BUILD_TARGET)
145+
@cp -R web/* $(GH_PAGES)/web
146+
@cp web/images/* $(GH_PAGES)/web/images
147+
@cp $(EXTENSION_SRC)/firefox/*.xpi $(GH_PAGES)/$(EXTENSION_SRC)/firefox/
118148
@cp $(GH_PAGES)/web/index.html.template $(GH_PAGES)/index.html;
149+
@mv -f $(GH_PAGES)/web/viewer-production.html $(GH_PAGES)/web/viewer.html;
119150
@cd $(GH_PAGES); git add -A;
120151
@echo
121152
@echo "Website built in $(GH_PAGES)."
@@ -135,22 +166,8 @@ pages-repo: | $(BUILD_DIR)
135166
fi;
136167
@mkdir -p $(GH_PAGES)/web;
137168
@mkdir -p $(GH_PAGES)/web/images;
169+
@mkdir -p $(GH_PAGES)/build;
138170
@mkdir -p $(GH_PAGES)/$(EXTENSION_SRC)/firefox;
139-
@mkdir -p $(GH_PAGES)/$(EXTENSION_SRC)/chrome;
140-
141-
$(GH_PAGES)/%.js: %.js
142-
@cp $< $@
143-
144-
$(GH_PAGES)/web/%: web/%
145-
@cp $< $@
146-
147-
$(GH_PAGES)/web/images/%: web/images/%
148-
@cp $< $@
149-
150-
$(GH_PAGES)/$(EXTENSION_SRC)/firefox/%: $(EXTENSION_SRC)/firefox/%
151-
@cp -R $< $@
152-
153-
$(GH_PAGES)/$(EXTENSION_SRC)/chrome/%: $(EXTENSION_SRC)/chrome/%
154171

155172
# # make compiler
156173
# #
@@ -169,29 +186,36 @@ $(GH_PAGES)/$(EXTENSION_SRC)/chrome/%: $(EXTENSION_SRC)/chrome/%
169186
#
170187
# This target produce a restartless firefox extension containing a
171188
# copy of the pdf.js source.
172-
CONTENT_DIR := firefox/content
189+
CONTENT_DIR := content
190+
FIREFOX_CONTENT_DIR := $(EXTENSION_SRC)/firefox/$(CONTENT_DIR)/
191+
CHROME_CONTENT_DIR := $(EXTENSION_SRC)/chrome/$(CONTENT_DIR)/
173192
PDF_WEB_FILES = \
174193
web/images \
175194
web/compatibility.js \
176195
web/viewer.css \
177196
web/viewer.js \
178-
web/viewer.html \
197+
web/viewer-production.html \
179198
$(NULL)
180-
extension:
199+
extension: | production
181200
# Copy a standalone version of pdf.js inside the content directory
182-
@rm -Rf $(EXTENSION_SRC)/$(CONTENT_DIR)/
183-
@mkdir -p $(EXTENSION_SRC)/$(CONTENT_DIR)/web
184-
@cp $(PDF_JS_FILES) $(EXTENSION_SRC)/$(CONTENT_DIR)/
185-
@cp -r $(PDF_WEB_FILES) $(EXTENSION_SRC)/$(CONTENT_DIR)/web/
201+
@rm -Rf $(FIREFOX_CONTENT_DIR)
202+
@mkdir -p $(FIREFOX_CONTENT_DIR)/$(BUILD_DIR)
203+
@mkdir -p $(FIREFOX_CONTENT_DIR)/web
204+
@cp $(BUILD_TARGET) $(FIREFOX_CONTENT_DIR)/$(BUILD_DIR)
205+
@cp -r $(PDF_WEB_FILES) $(FIREFOX_CONTENT_DIR)/web/
206+
@mv -f $(FIREFOX_CONTENT_DIR)/web/viewer-production.html $(FIREFOX_CONTENT_DIR)/web/viewer.html
186207

187208
# Create the xpi
188209
@cd $(EXTENSION_SRC)/firefox; zip -r $(FIREFOX_EXTENSION_NAME) *
189210
@echo "extension created: " $(FIREFOX_EXTENSION_NAME)
190211

191212
# Copy a standalone version of pdf.js inside the extension directory
192-
@cp $(PDF_JS_FILES) $(EXTENSION_SRC)/chrome/
193-
@mkdir -p $(EXTENSION_SRC)/chrome/web
194-
@cp -r $(PDF_WEB_FILES) $(EXTENSION_SRC)/chrome/web/
213+
@rm -Rf $(CHROME_CONTENT_DIR)
214+
@mkdir -p $(CHROME_CONTENT_DIR)/$(BUILD_DIR)
215+
@mkdir -p $(CHROME_CONTENT_DIR)/web
216+
@cp $(BUILD_TARGET) $(CHROME_CONTENT_DIR)/$(BUILD_DIR)
217+
@cp -r $(PDF_WEB_FILES) $(CHROME_CONTENT_DIR)/web/
218+
@mv -f $(CHROME_CONTENT_DIR)/web/viewer-production.html $(CHROME_CONTENT_DIR)/web/viewer.html
195219

196220
# Create the crx
197221
#TODO
@@ -211,5 +235,5 @@ clean:
211235
help:
212236
@echo "Read the comments in the Makefile for guidance.";
213237

214-
.PHONY:: all test browser-test font-test shell-test \
238+
.PHONY:: production test browser-test font-test shell-test \
215239
shell-msg lint clean web compiler help server

README.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,24 @@ successful.
2222

2323
For an online demo, visit:
2424

25-
+ http://andreasgal.github.com/pdf.js/web/viewer.html
25+
+ http://mozilla.github.com/pdf.js/web/viewer.html
2626

2727
This demo provides an interactive interface for displaying and browsing PDFs
2828
using the pdf.js API.
2929

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+
3038
### Getting the code
3139

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

34-
$ git clone git://github.com/andreasgal/pdf.js.git pdfjs
42+
$ git clone git://github.com/mozilla/pdf.js.git pdfjs
3543
$ cd pdfjs
3644

3745
Next, you need to start a local web server as some browsers don't allow opening
@@ -47,46 +55,56 @@ You can also view all the test pdf files on the right side serving
4755

4856
+ http://localhost:8888/test/pdfs/?frame
4957

50-
### Learning
58+
### Building pdf.js
5159

52-
Here are some initial pointers to help contributors get off the ground.
53-
Additional resources are available in a separate section below.
60+
In order to bundle all `src/` files into a final `pdf.js`, issue:
5461

55-
#### Introductory video
62+
$ make
5663

57-
Check out the presentation by our contributor Julian Viereck on the inner
58-
workings of PDF and pdf.js:
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).
5965

60-
+ http://www.youtube.com/watch?v=Iv15UY-4Fg8
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.
6171

6272
#### Hello world
6373

6474
For a "hello world" example, take a look at:
6575

66-
+ [examples/helloworld/hello.js](https://github.com/andreasgal/pdf.js/blob/master/examples/helloworld/hello.js)
76+
+ [examples/helloworld/hello.js](https://github.com/mozilla/pdf.js/blob/master/examples/helloworld/hello.js)
6777

6878
This example illustrates the bare minimum ingredients for integrating pdf.js
6979
in a custom project.
7080

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+
7189

7290

7391
## Contributing
7492

7593
pdf.js is a community-driven project, so contributors are always welcome.
7694
Simply fork our repo and contribute away. A great place to start is our
77-
[open issues](https://github.com/andreasgal/pdf.js/issues). For better consistency and
95+
[open issues](https://github.com/mozilla/pdf.js/issues). For better consistency and
7896
long-term stability, please do look around the code and try to follow our conventions.
7997
More information about the contributor process can be found on the
80-
[contributor wiki page](https://github.com/andreasgal/pdf.js/wiki/Contributing).
98+
[contributor wiki page](https://github.com/mozilla/pdf.js/wiki/Contributing).
8199

82100
If you don't want to hack on the project or have little spare time, __you still
83101
can help!__ Just open PDFs in the
84-
[online demo](http://andreasgal.github.com/pdf.js/web/viewer.html) and report
102+
[online demo](http://mozilla.github.com/pdf.js/web/viewer.html) and report
85103
any breakage in rendering.
86104

87105
Our Github contributors so far:
88106

89-
+ https://github.com/andreasgal/pdf.js/contributors
107+
+ https://github.com/mozilla/pdf.js/contributors
90108

91109
You can add your name to it! :)
92110

@@ -125,14 +143,14 @@ against reference images before merging pull requests.
125143

126144
See the bot repo for details:
127145

128-
+ https://github.com/arturadib/pdf.js-bot
146+
+ https://github.com/mozilla/pdf.js-bot
129147

130148

131149
## Additional resources
132150

133151
Our demo site is here:
134152

135-
+ http://andreasgal.github.com/pdf.js/web/viewer.html
153+
+ http://mozilla.github.com/pdf.js/web/viewer.html
136154

137155
You can read more about pdf.js here:
138156

examples/helloworld/hello.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
'use strict';
99

10-
getPdf('helloworld.pdf', function getPdfHelloWorld(data) {
10+
PDFJS.getPdf('helloworld.pdf', function getPdfHelloWorld(data) {
1111
//
1212
// Instantiate PDFDoc with PDF data
1313
//
14-
var pdf = new PDFDoc(data);
14+
var pdf = new PDFJS.PDFDoc(data);
1515
var page = pdf.getPage(1);
1616
var scale = 1.5;
1717

examples/helloworld/index.html

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,34 @@
22
<html>
33

44
<head>
5-
<!-- PDF.js-specific -->
6-
<script type="text/javascript" src="../../pdf.js"></script>
7-
<script type="text/javascript" src="../../metrics.js"></script>
8-
<script type="text/javascript" src="../../fonts.js"></script>
9-
<script type="text/javascript" src="../../glyphlist.js"></script>
5+
<!-- In production, only one script (pdf.js) is necessary -->
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>
1025

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>
1131
<script type="text/javascript" src="hello.js"></script>
12-
</head>
32+
</head>
1333

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

extensions/firefox/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
content/

0 commit comments

Comments
 (0)