Merge upstream

This commit is contained in:
Vivien Nicolas 2011-11-06 16:36:54 +01:00
commit 13cf9abfb4
28 changed files with 711 additions and 370 deletions

View File

@ -1,4 +1,4 @@
REPO = git@github.com:andreasgal/pdf.js.git REPO = git@github.com:mozilla/pdf.js.git
BUILD_DIR := build BUILD_DIR := build
BUILD_TARGET := $(BUILD_DIR)/pdf.js BUILD_TARGET := $(BUILD_DIR)/pdf.js
DEFAULT_BROWSERS := resources/browser_manifests/browser_manifest.json DEFAULT_BROWSERS := resources/browser_manifests/browser_manifest.json
@ -139,12 +139,11 @@ lint:
# TODO: Use the Closure compiler to optimize the pdf.js files. # TODO: Use the Closure compiler to optimize the pdf.js files.
# #
GH_PAGES = $(BUILD_DIR)/gh-pages GH_PAGES = $(BUILD_DIR)/gh-pages
web: | production extension compiler pages-repo \ web: | production extension compiler pages-repo
$(addprefix $(GH_PAGES)/, $(BUILD_TARGET)) \ @cp $(BUILD_TARGET) $(GH_PAGES)/$(BUILD_TARGET)
$(addprefix $(GH_PAGES)/, $(wildcard web/*.*)) \ @cp -R web/* $(GH_PAGES)/web
$(addprefix $(GH_PAGES)/, $(wildcard web/images/*.*)) \ @cp web/images/* $(GH_PAGES)/web/images
$(addprefix $(GH_PAGES)/, $(wildcard $(EXTENSION_SRC)/*.xpi)) @cp $(EXTENSION_SRC)/*.xpi $(GH_PAGES)/$(EXTENSION_SRC)
@cp $(GH_PAGES)/web/index.html.template $(GH_PAGES)/index.html; @cp $(GH_PAGES)/web/index.html.template $(GH_PAGES)/index.html;
@mv -f $(GH_PAGES)/web/viewer-production.html $(GH_PAGES)/web/viewer.html; @mv -f $(GH_PAGES)/web/viewer-production.html $(GH_PAGES)/web/viewer.html;
@cd $(GH_PAGES); git add -A; @cd $(GH_PAGES); git add -A;
@ -169,18 +168,6 @@ pages-repo: | $(BUILD_DIR)
@mkdir -p $(GH_PAGES)/build; @mkdir -p $(GH_PAGES)/build;
@mkdir -p $(GH_PAGES)/$(EXTENSION_SRC); @mkdir -p $(GH_PAGES)/$(EXTENSION_SRC);
$(GH_PAGES)/$(BUILD_DIR)/%.js: build/%.js
@cp $< $@
$(GH_PAGES)/web/%: web/%
@cp $< $@
$(GH_PAGES)/web/images/%: web/images/%
@cp $< $@
$(GH_PAGES)/$(EXTENSION_SRC)/%: $(EXTENSION_SRC)/%
@cp -R $< $@
# # make compiler # # make compiler
# # # #
# # This target downloads the Closure compiler, and places it in the # # This target downloads the Closure compiler, and places it in the

196
README.md
View File

@ -1 +1,195 @@
pdf.js has moved to: https://github.com/mozilla/pdf.js # pdf.js
## Overview
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.
## Getting started
### Online demo
For an online demo, visit:
+ http://mozilla.github.com/pdf.js/web/viewer.html
This demo provides an interactive interface for displaying and browsing PDFs
using the pdf.js API.
### Extension
A Firefox extension is also available:
+ http://mozilla.github.com/pdf.js/extensions/firefox/pdf.js.xpi
However, note that the extension might not reflect the latest source in our master branch.
### Getting the code
To get a local copy of the current code, clone it using git:
$ git clone git://github.com/mozilla/pdf.js.git pdfjs
$ cd pdfjs
Next, you need to start a local web server as some browsers don't allow opening
PDF files for a file:// url:
$ make server
If everything worked out, you can now serve
+ http://localhost:8888/web/viewer.html
You can also view all the test pdf files on the right side serving
+ http://localhost:8888/test/pdfs/?frame
### Building pdf.js
In order to bundle all `src/` files into a final `pdf.js`, issue:
$ make
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).
## Learning
Here are some initial pointers to help contributors get off the ground.
Additional resources are available in a separate section below.
#### Hello world
For a "hello world" example, take a look at:
+ [examples/helloworld/hello.js](https://github.com/mozilla/pdf.js/blob/master/examples/helloworld/hello.js)
This example illustrates the bare minimum ingredients for integrating pdf.js
in a custom project.
#### Introductory video
Check out the presentation by our contributor Julian Viereck on the inner
workings of PDF and pdf.js:
+ http://www.youtube.com/watch?v=Iv15UY-4Fg8
## Contributing
pdf.js is a community-driven project, so contributors are always welcome.
Simply fork our repo and contribute away. A great place to start is our
[open 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.
More information about the contributor process can be found on the
[contributor wiki page](https://github.com/mozilla/pdf.js/wiki/Contributing).
If you don't want to hack on the project or have little spare time, __you still
can help!__ Just open PDFs in the
[online demo](http://mozilla.github.com/pdf.js/web/viewer.html) and report
any breakage in rendering.
Our Github contributors so far:
+ https://github.com/mozilla/pdf.js/contributors
You can add your name to it! :)
## Running the tests
pdf.js comes with browser-level regression tests that allow one to probe
whether it's able to successfully parse PDFs, as well as compare its output
against reference images, pixel-by-pixel.
To run the tests, first configure the browser manifest file at:
test/resources/browser_manifests/browser_manifest.json
Sample manifests for different platforms are provided in that directory.
To run all the bundled tests, type:
$ make test
and cross your fingers. Different types of tests are available, see the test
manifest file at:
test/test_manifest.json
The test type `eq` tests whether the output images are identical to reference
images. The test type `load` simply tests whether the file loads without
raising any errors.
## Running tests through our bot
If you are a reviewer, you can use our remote bot to issue comprehensive tests
against reference images before merging pull requests.
See the bot repo for details:
+ https://github.com/mozilla/pdf.js-bot
## Additional resources
Our demo site is here:
+ http://mozilla.github.com/pdf.js/web/viewer.html
You can read more about pdf.js here:
+ http://andreasgal.com/2011/06/15/pdf-js/
+ http://blog.mozilla.com/cjones/2011/06/15/overview-of-pdf-js-guts/
Talk to us on IRC:
+ #pdfjs on irc.mozilla.org
Join our mailing list:
+ dev-pdf-js@lists.mozilla.org
Subscribe either using lists.mozilla.org or Google Groups:
+ https://lists.mozilla.org/listinfo/dev-pdf-js
+ https://groups.google.com/group/mozilla.dev.pdf-js/topics
Follow us on twitter: @pdfjs
+ http://twitter.com/#!/pdfjs
## PDF-related resources
A really basic overview of PDF is described here:
+ http://partners.adobe.com/public/developer/en/livecycle/lc_pdf_overview_format.pdf
A more detailed file example:
+ http://gnupdf.org/Introduction_to_PDF
The PDF specification itself is an ISO and not freely available. However, there is
a "PDF Reference" from Adobe:
+ http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_1-7.pdf
Recommended chapters to read: "2. Overview", "3.4 File Structure",
"4.1 Graphics Objects" that lists the PDF commands.

View File

@ -3,27 +3,33 @@
<head> <head>
<!-- In production, only one script (pdf.js) is necessary --> <!-- In production, only one script (pdf.js) is necessary -->
<script type="text/javascript" src="../../src/core.js"></script> <!-- In production, change the content of PDFJS.workerSrc below -->
<script type="text/javascript" src="../../src/util.js"></script> <script type="text/javascript" src="../../src/core.js"></script>
<script type="text/javascript" src="../../src/canvas.js"></script> <script type="text/javascript" src="../../src/util.js"></script>
<script type="text/javascript" src="../../src/obj.js"></script> <script type="text/javascript" src="../../src/canvas.js"></script>
<script type="text/javascript" src="../../src/function.js"></script> <script type="text/javascript" src="../../src/obj.js"></script>
<script type="text/javascript" src="../../src/charsets.js"></script> <script type="text/javascript" src="../../src/function.js"></script>
<script type="text/javascript" src="../../src/cidmaps.js"></script> <script type="text/javascript" src="../../src/charsets.js"></script>
<script type="text/javascript" src="../../src/colorspace.js"></script> <script type="text/javascript" src="../../src/cidmaps.js"></script>
<script type="text/javascript" src="../../src/crypto.js"></script> <script type="text/javascript" src="../../src/colorspace.js"></script>
<script type="text/javascript" src="../../src/evaluator.js"></script> <script type="text/javascript" src="../../src/crypto.js"></script>
<script type="text/javascript" src="../../src/fonts.js"></script> <script type="text/javascript" src="../../src/evaluator.js"></script>
<script type="text/javascript" src="../../src/glyphlist.js"></script> <script type="text/javascript" src="../../src/fonts.js"></script>
<script type="text/javascript" src="../../src/image.js"></script> <script type="text/javascript" src="../../src/glyphlist.js"></script>
<script type="text/javascript" src="../../src/metrics.js"></script> <script type="text/javascript" src="../../src/image.js"></script>
<script type="text/javascript" src="../../src/parser.js"></script> <script type="text/javascript" src="../../src/metrics.js"></script>
<script type="text/javascript" src="../../src/pattern.js"></script> <script type="text/javascript" src="../../src/parser.js"></script>
<script type="text/javascript" src="../../src/stream.js"></script> <script type="text/javascript" src="../../src/pattern.js"></script>
<script type="text/javascript" src="../../src/worker.js"></script> <script type="text/javascript" src="../../src/stream.js"></script>
<script type="text/javascript" src="../../src/worker.js"></script>
<script type="text/javascript">
// Specify the main script used to create a new PDF.JS web worker.
// In production, change this to point to the combined `pdf.js` file.
PDFJS.workerSrc = '../../src/worker_loader.js';
</script>
<script type="text/javascript" src="hello.js"></script> <script type="text/javascript" src="hello.js"></script>
</head> </head>
<body> <body>
<canvas id="the-canvas" style="border:1px solid black;"/> <canvas id="the-canvas" style="border:1px solid black;"/>

View File

@ -16,21 +16,31 @@ function log(str) {
function startup(aData, aReason) { function startup(aData, aReason) {
let manifestPath = 'chrome.manifest'; let manifestPath = 'chrome.manifest';
let file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile); let manifest = Cc['@mozilla.org/file/local;1']
.createInstance(Ci.nsILocalFile);
try { try {
file.initWithPath(aData.installPath.path); manifest.initWithPath(aData.installPath.path);
file.append(manifestPath); manifest.append(manifestPath);
Cm.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(file); Cm.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(manifest);
Services.prefs.setBoolPref('extensions.pdf.js.active', true);
} catch (e) { } catch (e) {
log(e); log(e);
} }
} }
function shutdown(aData, aReason) { function shutdown(aData, aReason) {
if (Services.prefs.getBoolPref('extensions.pdf.js.active'))
Services.prefs.setBoolPref('extensions.pdf.js.active', false);
} }
function install(aData, aReason) { function install(aData, aReason) {
let url = 'chrome://pdf.js/content/web/viewer.html?file=%s'; let url = 'chrome://pdf.js/content/web/viewer.html?file=%s';
Services.prefs.setCharPref('extensions.pdf.js.url', url); Services.prefs.setCharPref('extensions.pdf.js.url', url);
Services.prefs.setBoolPref('extensions.pdf.js.active', false);
}
function uninstall(aData, aReason) {
Services.prefs.clearUserPref('extensions.pdf.js.url');
Services.prefs.clearUserPref('extensions.pdf.js.active');
} }

View File

@ -32,6 +32,9 @@ pdfContentHandler.prototype = {
if (!(aRequest instanceof Ci.nsIChannel)) if (!(aRequest instanceof Ci.nsIChannel))
throw NS_ERROR_WONT_HANDLE_CONTENT; throw NS_ERROR_WONT_HANDLE_CONTENT;
if (!Services.prefs.getBoolPref('extensions.pdf.js.active'))
throw NS_ERROR_WONT_HANDLE_CONTENT;
let window = null; let window = null;
let callbacks = aRequest.notificationCallbacks || let callbacks = aRequest.notificationCallbacks ||
aRequest.loadGroup.notificationCallbacks; aRequest.loadGroup.notificationCallbacks;
@ -53,7 +56,7 @@ pdfContentHandler.prototype = {
throw NS_ERROR_WONT_HANDLE_CONTENT; throw NS_ERROR_WONT_HANDLE_CONTENT;
aRequest.cancel(Cr.NS_BINDING_ABORTED); aRequest.cancel(Cr.NS_BINDING_ABORTED);
window.location = url.replace('%s', targetUrl); window.location = url.replace('%s', encodeURIComponent(targetUrl));
}, },
classID: Components.ID('{2278dfd0-b75c-11e0-8257-1ba3d93c9f1a}'), classID: Components.ID('{2278dfd0-b75c-11e0-8257-1ba3d93c9f1a}'),

View File

@ -19,6 +19,6 @@
<em:unpack>true</em:unpack> <em:unpack>true</em:unpack>
<em:creator>Vivien Nicolas</em:creator> <em:creator>Vivien Nicolas</em:creator>
<em:description>pdf.js uri loader</em:description> <em:description>pdf.js uri loader</em:description>
<em:homepageURL>https://github.com/andreasgal/pdf.js/</em:homepageURL> <em:homepageURL>https://github.com/mozilla/pdf.js/</em:homepageURL>
</Description> </Description>
</RDF> </RDF>

View File

@ -24,15 +24,18 @@ var CanvasExtraState = (function canvasExtraState() {
this.wordSpacing = 0; this.wordSpacing = 0;
this.textHScale = 1; this.textHScale = 1;
// Color spaces // Color spaces
this.fillColorSpace = new DeviceGrayCS; this.fillColorSpace = new DeviceGrayCS();
this.fillColorSpaceObj = null; this.fillColorSpaceObj = null;
this.strokeColorSpace = new DeviceGrayCS; this.strokeColorSpace = new DeviceGrayCS();
this.strokeColorSpaceObj = null; this.strokeColorSpaceObj = null;
this.fillColorObj = null; this.fillColorObj = null;
this.strokeColorObj = null; this.strokeColorObj = null;
// Default fore and background colors // Default fore and background colors
this.fillColor = '#000000'; this.fillColor = '#000000';
this.strokeColor = '#000000'; this.strokeColor = '#000000';
// Note: fill alpha applies to all non-stroking operations
this.fillAlpha = 1;
this.strokeAlpha = 1;
this.old = old; this.old = old;
} }
@ -122,7 +125,7 @@ var CanvasGraphics = (function canvasGraphics() {
this[fnArray[i]].apply(this, argsArray[i]); this[fnArray[i]].apply(this, argsArray[i]);
} else { } else {
var deps = argsArray[i]; var deps = argsArray[i];
for (var n = 0; n < deps.length; n++) { for (var n = 0, nn = deps.length; n < nn; n++) {
var depObjId = deps[n]; var depObjId = deps[n];
// If the promise isn't resolved yet, add the continueCallback // If the promise isn't resolved yet, add the continueCallback
@ -181,7 +184,7 @@ var CanvasGraphics = (function canvasGraphics() {
TODO('set flatness: ' + flatness); TODO('set flatness: ' + flatness);
}, },
setGState: function canvasGraphicsSetGState(states) { setGState: function canvasGraphicsSetGState(states) {
for (var i = 0; i < states.length; i++) { for (var i = 0, ii = states.length; i < ii; i++) {
var state = states[i]; var state = states[i];
var key = state[0]; var key = state[0];
var value = state[1]; var value = state[1];
@ -211,6 +214,13 @@ var CanvasGraphics = (function canvasGraphics() {
case 'Font': case 'Font':
this.setFont(state[1], state[2]); this.setFont(state[1], state[2]);
break; break;
case 'CA':
this.current.strokeAlpha = state[1];
break;
case 'ca':
this.current.fillAlpha = state[1];
this.ctx.globalAlpha = state[1];
break;
} }
} }
}, },
@ -259,9 +269,13 @@ var CanvasGraphics = (function canvasGraphics() {
rectangle: function canvasGraphicsRectangle(x, y, width, height) { rectangle: function canvasGraphicsRectangle(x, y, width, height) {
this.ctx.rect(x, y, width, height); this.ctx.rect(x, y, width, height);
}, },
stroke: function canvasGraphicsStroke() { stroke: function canvasGraphicsStroke(consumePath) {
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
var ctx = this.ctx; var ctx = this.ctx;
var strokeColor = this.current.strokeColor; var strokeColor = this.current.strokeColor;
// For stroke we want to temporarily change the global alpha to the
// stroking alpha.
ctx.globalAlpha = this.current.strokeAlpha;
if (strokeColor && strokeColor.hasOwnProperty('type') && if (strokeColor && strokeColor.hasOwnProperty('type') &&
strokeColor.type === 'Pattern') { strokeColor.type === 'Pattern') {
// for patterns, we transform to pattern space, calculate // for patterns, we transform to pattern space, calculate
@ -273,14 +287,17 @@ var CanvasGraphics = (function canvasGraphics() {
} else { } else {
ctx.stroke(); ctx.stroke();
} }
if (consumePath)
this.consumePath(); this.consumePath();
// Restore the global alpha to the fill alpha
ctx.globalAlpha = this.current.fillAlpha;
}, },
closeStroke: function canvasGraphicsCloseStroke() { closeStroke: function canvasGraphicsCloseStroke() {
this.closePath(); this.closePath();
this.stroke(); this.stroke();
}, },
fill: function canvasGraphicsFill() { fill: function canvasGraphicsFill(consumePath) {
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
var ctx = this.ctx; var ctx = this.ctx;
var fillColor = this.current.fillColor; var fillColor = this.current.fillColor;
@ -293,8 +310,8 @@ var CanvasGraphics = (function canvasGraphics() {
} else { } else {
ctx.fill(); ctx.fill();
} }
if (consumePath)
this.consumePath(); this.consumePath();
}, },
eoFill: function canvasGraphicsEoFill() { eoFill: function canvasGraphicsEoFill() {
var savedFillRule = this.setEOFillRule(); var savedFillRule = this.setEOFillRule();
@ -302,29 +319,8 @@ var CanvasGraphics = (function canvasGraphics() {
this.restoreFillRule(savedFillRule); this.restoreFillRule(savedFillRule);
}, },
fillStroke: function canvasGraphicsFillStroke() { fillStroke: function canvasGraphicsFillStroke() {
var ctx = this.ctx; this.fill(false);
this.stroke(false);
var fillColor = this.current.fillColor;
if (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') {
ctx.save();
ctx.fillStyle = fillColor.getPattern(ctx);
ctx.fill();
ctx.restore();
} else {
ctx.fill();
}
var strokeColor = this.current.strokeColor;
if (strokeColor && strokeColor.hasOwnProperty('type') &&
strokeColor.type === 'Pattern') {
ctx.save();
ctx.strokeStyle = strokeColor.getPattern(ctx);
ctx.stroke();
ctx.restore();
} else {
ctx.stroke();
}
this.consumePath(); this.consumePath();
}, },

View File

@ -23,7 +23,7 @@ var ColorSpace = (function colorSpaceColorSpace() {
}; };
constructor.parse = function colorSpaceParse(cs, xref, res) { constructor.parse = function colorSpaceParse(cs, xref, res) {
var IR = constructor.parseToIR(cs, xref, res, true); var IR = constructor.parseToIR(cs, xref, res);
if (IR instanceof SeparationCS) if (IR instanceof SeparationCS)
return IR; return IR;
@ -31,12 +31,7 @@ var ColorSpace = (function colorSpaceColorSpace() {
}; };
constructor.fromIR = function colorSpaceFromIR(IR) { constructor.fromIR = function colorSpaceFromIR(IR) {
var name; var name = isArray(IR) ? IR[0] : IR;
if (isArray(IR)) {
name = IR[0];
} else {
name = IR;
}
switch (name) { switch (name) {
case 'DeviceGrayCS': case 'DeviceGrayCS':
@ -46,33 +41,28 @@ var ColorSpace = (function colorSpaceColorSpace() {
case 'DeviceCmykCS': case 'DeviceCmykCS':
return new DeviceCmykCS(); return new DeviceCmykCS();
case 'PatternCS': case 'PatternCS':
var baseCS = IR[1]; var basePatternCS = IR[1];
if (baseCS == null) { if (basePatternCS)
return new PatternCS(null); basePatternCS = ColorSpace.fromIR(basePatternCS);
} else { return new PatternCS(basePatternCS);
return new PatternCS(ColorSpace.fromIR(baseCS));
}
case 'IndexedCS': case 'IndexedCS':
var baseCS = IR[1]; var baseIndexedCS = IR[1];
var hiVal = IR[2]; var hiVal = IR[2];
var lookup = IR[3]; var lookup = IR[3];
return new IndexedCS(ColorSpace.fromIR(baseCS), hiVal, lookup); return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
case 'SeparationCS': case 'SeparationCS':
var alt = IR[1]; var alt = IR[1];
var tintFnIR = IR[2]; var tintFnIR = IR[2];
return new SeparationCS( return new SeparationCS(ColorSpace.fromIR(alt),
ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
PDFFunction.fromIR(tintFnIR)
);
default: default:
error('Unkown name ' + name); error('Unkown name ' + name);
} }
return null; return null;
} };
constructor.parseToIR = function colorSpaceParseToIR(cs, xref, res, constructor.parseToIR = function colorSpaceParseToIR(cs, xref, res) {
parseOnly) {
if (isName(cs)) { if (isName(cs)) {
var colorSpaces = xref.fetchIfRef(res.get('ColorSpace')); var colorSpaces = xref.fetchIfRef(res.get('ColorSpace'));
if (isDict(colorSpaces)) { if (isDict(colorSpaces)) {
@ -83,9 +73,10 @@ var ColorSpace = (function colorSpaceColorSpace() {
} }
cs = xref.fetchIfRef(cs); cs = xref.fetchIfRef(cs);
var mode;
if (isName(cs)) { if (isName(cs)) {
var mode = cs.name; mode = cs.name;
this.mode = mode; this.mode = mode;
switch (mode) { switch (mode) {
@ -104,7 +95,7 @@ var ColorSpace = (function colorSpaceColorSpace() {
error('unrecognized colorspace ' + mode); error('unrecognized colorspace ' + mode);
} }
} else if (isArray(cs)) { } else if (isArray(cs)) {
var mode = cs[0].name; mode = cs[0].name;
this.mode = mode; this.mode = mode;
switch (mode) { switch (mode) {
@ -133,15 +124,15 @@ var ColorSpace = (function colorSpaceColorSpace() {
return 'DeviceCmykCS'; return 'DeviceCmykCS';
break; break;
case 'Pattern': case 'Pattern':
var baseCS = cs[1]; var basePatternCS = cs[1];
if (baseCS) if (basePatternCS)
baseCS = ColorSpace.parseToIR(baseCS, xref, res); basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
return ['PatternCS', baseCS]; return ['PatternCS', basePatternCS];
case 'Indexed': case 'Indexed':
var baseCS = ColorSpace.parseToIR(cs[1], xref, res); var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
var hiVal = cs[2] + 1; var hiVal = cs[2] + 1;
var lookup = xref.fetchIfRef(cs[3]); var lookup = xref.fetchIfRef(cs[3]);
return ['IndexedCS', baseCS, hiVal, lookup]; return ['IndexedCS', baseIndexedCS, hiVal, lookup];
case 'Separation': case 'Separation':
var alt = ColorSpace.parseToIR(cs[2], xref, res); var alt = ColorSpace.parseToIR(cs[2], xref, res);
var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3])); var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
@ -165,7 +156,6 @@ var SeparationCS = (function separationCS() {
this.name = 'Separation'; this.name = 'Separation';
this.numComps = 1; this.numComps = 1;
this.defaultColor = [1]; this.defaultColor = [1];
this.base = base; this.base = base;
this.tintFn = tintFn; this.tintFn = tintFn;
} }
@ -179,12 +169,11 @@ var SeparationCS = (function separationCS() {
var tintFn = this.tintFn; var tintFn = this.tintFn;
var base = this.base; var base = this.base;
var scale = 1 / ((1 << bits) - 1); var scale = 1 / ((1 << bits) - 1);
var length = input.length; var length = input.length;
var pos = 0; var pos = 0;
var numComps = base.numComps; var numComps = base.numComps;
var baseBuf = new Uint8Array(numComps * length); var baseBuf = new Uint8Array(numComps * length);
for (var i = 0; i < length; ++i) { for (var i = 0; i < length; ++i) {
var scaled = input[i] * scale; var scaled = input[i] * scale;
var tinted = tintFn([scaled]); var tinted = tintFn([scaled]);
@ -213,13 +202,13 @@ var IndexedCS = (function indexedCS() {
this.name = 'Indexed'; this.name = 'Indexed';
this.numComps = 1; this.numComps = 1;
this.defaultColor = [0]; this.defaultColor = [0];
this.base = base; this.base = base;
var baseNumComps = base.numComps;
this.highVal = highVal; this.highVal = highVal;
var baseNumComps = base.numComps;
var length = baseNumComps * highVal; var length = baseNumComps * highVal;
var lookupArray = new Uint8Array(length); var lookupArray = new Uint8Array(length);
if (isStream(lookup)) { if (isStream(lookup)) {
var bytes = lookup.getBytes(length); var bytes = lookup.getBytes(length);
lookupArray.set(bytes); lookupArray.set(bytes);
@ -235,7 +224,6 @@ var IndexedCS = (function indexedCS() {
constructor.prototype = { constructor.prototype = {
getRgb: function indexcs_getRgb(color) { getRgb: function indexcs_getRgb(color) {
var numComps = this.base.numComps; var numComps = this.base.numComps;
var start = color[0] * numComps; var start = color[0] * numComps;
var c = []; var c = [];
@ -249,9 +237,9 @@ var IndexedCS = (function indexedCS() {
var numComps = base.numComps; var numComps = base.numComps;
var lookup = this.lookup; var lookup = this.lookup;
var length = input.length; var length = input.length;
var baseBuf = new Uint8Array(length * numComps); var baseBuf = new Uint8Array(length * numComps);
var baseBufPos = 0; var baseBufPos = 0;
for (var i = 0; i < length; ++i) { for (var i = 0; i < length; ++i) {
var lookupPos = input[i] * numComps; var lookupPos = input[i] * numComps;
for (var j = 0; j < numComps; ++j) { for (var j = 0; j < numComps; ++j) {
@ -294,7 +282,7 @@ var DeviceGrayCS = (function deviceGrayCS() {
})(); })();
var DeviceRgbCS = (function deviceRgbCS() { var DeviceRgbCS = (function deviceRgbCS() {
function constructor(bits) { function constructor() {
this.name = 'DeviceRGB'; this.name = 'DeviceRGB';
this.numComps = 3; this.numComps = 3;
this.defaultColor = [0, 0, 0]; this.defaultColor = [0, 0, 0];
@ -337,41 +325,41 @@ var DeviceCmykCS = (function deviceCmykCS() {
r += 0.1373 * x; r += 0.1373 * x;
g += 0.1216 * x; g += 0.1216 * x;
b += 0.1255 * x; b += 0.1255 * x;
x = c1 * m1 * y * k1; // 0 0 1 0 x = c1 * m1 * y * k1; // 0 0 1 0
r += x; r += x;
g += 0.9490 * x; g += 0.9490 * x;
x = c1 * m1 * y * k; // 0 0 1 1 x = c1 * m1 * y * k; // 0 0 1 1
r += 0.1098 * x; r += 0.1098 * x;
g += 0.1020 * x; g += 0.1020 * x;
x = c1 * m * y1 * k1; // 0 1 0 0 x = c1 * m * y1 * k1; // 0 1 0 0
r += 0.9255 * x; r += 0.9255 * x;
b += 0.5490 * x; b += 0.5490 * x;
x = c1 * m * y1 * k; // 0 1 0 1 x = c1 * m * y1 * k; // 0 1 0 1
r += 0.1412 * x; r += 0.1412 * x;
x = c1 * m * y * k1; // 0 1 1 0 x = c1 * m * y * k1; // 0 1 1 0
r += 0.9294 * x; r += 0.9294 * x;
g += 0.1098 * x; g += 0.1098 * x;
b += 0.1412 * x; b += 0.1412 * x;
x = c1 * m * y * k; // 0 1 1 1 x = c1 * m * y * k; // 0 1 1 1
r += 0.1333 * x; r += 0.1333 * x;
x = c * m1 * y1 * k1; // 1 0 0 0 x = c * m1 * y1 * k1; // 1 0 0 0
g += 0.6784 * x; g += 0.6784 * x;
b += 0.9373 * x; b += 0.9373 * x;
x = c * m1 * y1 * k; // 1 0 0 1 x = c * m1 * y1 * k; // 1 0 0 1
g += 0.0588 * x; g += 0.0588 * x;
b += 0.1412 * x; b += 0.1412 * x;
x = c * m1 * y * k1; // 1 0 1 0 x = c * m1 * y * k1; // 1 0 1 0
g += 0.6510 * x; g += 0.6510 * x;
b += 0.3137 * x; b += 0.3137 * x;
x = c * m1 * y * k; // 1 0 1 1 x = c * m1 * y * k; // 1 0 1 1
g += 0.0745 * x; g += 0.0745 * x;
x = c * m * y1 * k1; // 1 1 0 0 x = c * m * y1 * k1; // 1 1 0 0
r += 0.1804 * x; r += 0.1804 * x;
g += 0.1922 * x; g += 0.1922 * x;
b += 0.5725 * x; b += 0.5725 * x;
x = c * m * y1 * k; // 1 1 0 1 x = c * m * y1 * k; // 1 1 0 1
b += 0.0078 * x; b += 0.0078 * x;
x = c * m * y * k1; // 1 1 1 0 x = c * m * y * k1; // 1 1 1 0
r += 0.2118 * x; r += 0.2118 * x;
g += 0.2119 * x; g += 0.2119 * x;
b += 0.2235 * x; b += 0.2235 * x;

View File

@ -7,7 +7,6 @@ var globalScope = (typeof window === 'undefined') ? this : window;
var ERRORS = 0, WARNINGS = 1, TODOS = 5; var ERRORS = 0, WARNINGS = 1, TODOS = 5;
var verbosity = WARNINGS; var verbosity = WARNINGS;
var useWorker = false;
// The global PDFJS object exposes the API // The global PDFJS object exposes the API
// In production, it will be declared outside a global wrapper // In production, it will be declared outside a global wrapper
@ -16,6 +15,10 @@ if (!globalScope.PDFJS) {
globalScope.PDFJS = {}; globalScope.PDFJS = {};
} }
// Temporarily disabling workers until 'localhost' FF bugfix lands:
// https://bugzilla.mozilla.org/show_bug.cgi?id=683280
globalScope.PDFJS.disableWorker = true;
// getPdf() // getPdf()
// Convenience function to perform binary Ajax GET // Convenience function to perform binary Ajax GET
// Usage: getPdf('http://...', callback) // Usage: getPdf('http://...', callback)
@ -199,13 +202,13 @@ var Page = (function pagePage() {
var pe = this.pe = new PartialEvaluator( var pe = this.pe = new PartialEvaluator(
xref, handler, 'p' + this.pageNumber + '_'); xref, handler, 'p' + this.pageNumber + '_');
var IRQueue = {}; var IRQueue = {};
return this.IRQueue = pe.getIRQueue( return (this.IRQueue = pe.getIRQueue(content, resources, IRQueue,
content, resources, IRQueue, dependency); dependency));
}, },
ensureFonts: function pageEnsureFonts(fonts, callback) { ensureFonts: function pageEnsureFonts(fonts, callback) {
// Convert the font names to the corresponding font obj. // Convert the font names to the corresponding font obj.
for (var i = 0; i < fonts.length; i++) { for (var i = 0, ii = fonts.length; i < ii; i++) {
fonts[i] = this.objs.objs[fonts[i]].data; fonts[i] = this.objs.objs[fonts[i]].data;
} }
@ -470,103 +473,136 @@ var PDFDoc = (function pdfDoc() {
this.objs = new PDFObjects(); this.objs = new PDFObjects();
this.pageCache = []; this.pageCache = [];
this.workerReadyPromise = new Promise('workerReady');
if (useWorker) { // If worker support isn't disabled explicit and the browser has worker
var worker = new Worker('../src/worker_loader.js'); // support, create a new web worker and test if it/the browser fullfills
// all requirements to run parts of pdf.js in a web worker.
// Right now, the requirement is, that an Uint8Array is still an Uint8Array
// as it arrives on the worker. Chrome added this with version 15.
if (!globalScope.PDFJS.disableWorker && typeof Worker !== 'undefined') {
var workerSrc = PDFJS.workerSrc;
if (typeof workerSrc === 'undefined') {
throw 'No PDFJS.workerSrc specified';
}
var worker = new Worker(workerSrc);
var messageHandler = new MessageHandler('main', worker);
// Tell the worker the file it was created from.
messageHandler.send('workerSrc', workerSrc);
messageHandler.on('test', function pdfDocTest(supportTypedArray) {
if (supportTypedArray) {
this.worker = worker;
this.setupMessageHandler(messageHandler);
} else {
this.setupFakeWorker();
}
}.bind(this));
var testObj = new Uint8Array(1);
messageHandler.send('test', testObj);
} else { } else {
// If we don't use a worker, just post/sendMessage to the main thread. this.setupFakeWorker();
var worker = {
postMessage: function pdfDocPostMessage(obj) {
worker.onmessage({data: obj});
},
terminate: function pdfDocTerminate() {}
};
} }
this.worker = worker;
this.fontsLoading = {}; this.fontsLoading = {};
var processorHandler = this.processorHandler =
new MessageHandler('main', worker);
processorHandler.on('page', function pdfDocPage(data) {
var pageNum = data.pageNum;
var page = this.pageCache[pageNum];
var depFonts = data.depFonts;
page.startRenderingFromIRQueue(data.IRQueue, depFonts);
}, this);
processorHandler.on('obj', function pdfDocObj(data) {
var id = data[0];
var type = data[1];
switch (type) {
case 'JpegStream':
var IR = data[2];
new JpegImage(id, IR, this.objs);
break;
case 'Font':
var name = data[2];
var file = data[3];
var properties = data[4];
if (file) {
var fontFileDict = new Dict();
fontFileDict.map = file.dict.map;
var fontFile = new Stream(file.bytes, file.start,
file.end - file.start, fontFileDict);
// Check if this is a FlateStream. Otherwise just use the created
// Stream one. This makes complex_ttf_font.pdf work.
var cmf = file.bytes[0];
if ((cmf & 0x0f) == 0x08) {
file = new FlateStream(fontFile);
} else {
file = fontFile;
}
}
// For now, resolve the font object here direclty. The real font
// object is then created in FontLoader.bind().
this.objs.resolve(id, {
name: name,
file: file,
properties: properties
});
break;
default:
throw 'Got unkown object type ' + type;
}
}, this);
processorHandler.on('font_ready', function pdfDocFontReady(data) {
var id = data[0];
var font = new FontShape(data[1]);
// If there is no string, then there is nothing to attach to the DOM.
if (!font.str) {
this.objs.resolve(id, font);
} else {
this.objs.setData(id, font);
}
}.bind(this));
if (!useWorker) {
// If the main thread is our worker, setup the handling for the messages
// the main thread sends to it self.
WorkerProcessorHandler.setup(processorHandler);
}
this.workerReadyPromise = new Promise('workerReady');
setTimeout(function pdfDocFontReadySetTimeout() {
processorHandler.send('doc', this.data);
this.workerReadyPromise.resolve(true);
}.bind(this));
} }
constructor.prototype = { constructor.prototype = {
setupFakeWorker: function() {
// If we don't use a worker, just post/sendMessage to the main thread.
var fakeWorker = {
postMessage: function pdfDocPostMessage(obj) {
fakeWorker.onmessage({data: obj});
},
terminate: function pdfDocTerminate() {}
};
var messageHandler = new MessageHandler('main', fakeWorker);
this.setupMessageHandler(messageHandler);
// If the main thread is our worker, setup the handling for the messages
// the main thread sends to it self.
WorkerMessageHandler.setup(messageHandler);
},
setupMessageHandler: function(messageHandler) {
this.messageHandler = messageHandler;
messageHandler.on('page', function pdfDocPage(data) {
var pageNum = data.pageNum;
var page = this.pageCache[pageNum];
var depFonts = data.depFonts;
page.startRenderingFromIRQueue(data.IRQueue, depFonts);
}, this);
messageHandler.on('obj', function pdfDocObj(data) {
var id = data[0];
var type = data[1];
switch (type) {
case 'JpegStream':
var IR = data[2];
new JpegImage(id, IR, this.objs);
break;
case 'Font':
var name = data[2];
var file = data[3];
var properties = data[4];
if (file) {
var fontFileDict = new Dict();
fontFileDict.map = file.dict.map;
var fontFile = new Stream(file.bytes, file.start,
file.end - file.start, fontFileDict);
// Check if this is a FlateStream. Otherwise just use the created
// Stream one. This makes complex_ttf_font.pdf work.
var cmf = file.bytes[0];
if ((cmf & 0x0f) == 0x08) {
file = new FlateStream(fontFile);
} else {
file = fontFile;
}
}
// For now, resolve the font object here direclty. The real font
// object is then created in FontLoader.bind().
this.objs.resolve(id, {
name: name,
file: file,
properties: properties
});
break;
default:
throw 'Got unkown object type ' + type;
}
}, this);
messageHandler.on('font_ready', function pdfDocFontReady(data) {
var id = data[0];
var font = new FontShape(data[1]);
// If there is no string, then there is nothing to attach to the DOM.
if (!font.str) {
this.objs.resolve(id, font);
} else {
this.objs.setData(id, font);
}
}.bind(this));
setTimeout(function pdfDocFontReadySetTimeout() {
messageHandler.send('doc', this.data);
this.workerReadyPromise.resolve(true);
}.bind(this));
},
get numPages() { get numPages() {
return this.pdf.numPages; return this.pdf.numPages;
}, },
@ -574,7 +610,7 @@ var PDFDoc = (function pdfDoc() {
startRendering: function pdfDocStartRendering(page) { startRendering: function pdfDocStartRendering(page) {
// The worker might not be ready to receive the page request yet. // The worker might not be ready to receive the page request yet.
this.workerReadyPromise.then(function pdfDocStartRenderingThen() { this.workerReadyPromise.then(function pdfDocStartRenderingThen() {
this.processorHandler.send('page_request', page.pageNumber + 1); this.messageHandler.send('page_request', page.pageNumber + 1);
}.bind(this)); }.bind(this));
}, },
@ -587,7 +623,7 @@ var PDFDoc = (function pdfDoc() {
// to the CanvasGraphics and so on. // to the CanvasGraphics and so on.
page.objs = this.objs; page.objs = this.objs;
page.pdf = this; page.pdf = this;
return this.pageCache[n] = page; return (this.pageCache[n] = page);
}, },
destroy: function pdfDocDestroy() { destroy: function pdfDocDestroy() {

View File

@ -338,7 +338,7 @@ var AES128Cipher = (function aes128Cipher() {
} }
function decryptBlock2(data) { function decryptBlock2(data) {
var i, j, sourceLength = data.length, var i, j, ii, sourceLength = data.length,
buffer = this.buffer, bufferLength = this.bufferPosition, buffer = this.buffer, bufferLength = this.bufferPosition,
result = [], iv = this.iv; result = [], iv = this.iv;
for (i = 0; i < sourceLength; ++i) { for (i = 0; i < sourceLength; ++i) {
@ -366,7 +366,7 @@ var AES128Cipher = (function aes128Cipher() {
return result[0]; return result[0];
// combining plain text blocks into one // combining plain text blocks into one
var output = new Uint8Array(16 * result.length); var output = new Uint8Array(16 * result.length);
for (i = 0, j = 0; i < result.length; ++i, j += 16) for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16)
output.set(result[i], j); output.set(result[i], j);
return output; return output;
} }

View File

@ -123,7 +123,7 @@ var PartialEvaluator = (function partialEvaluator() {
function insertDependency(depList) { function insertDependency(depList) {
fnArray.push('dependency'); fnArray.push('dependency');
argsArray.push(depList); argsArray.push(depList);
for (var i = 0; i < depList.length; i++) { for (var i = 0, ii = depList.length; i < ii; i++) {
var dep = depList[i]; var dep = depList[i];
if (dependency.indexOf(dep) == -1) { if (dependency.indexOf(dep) == -1) {
dependency.push(depList[i]); dependency.push(depList[i]);
@ -405,6 +405,8 @@ var PartialEvaluator = (function partialEvaluator() {
case 'D': case 'D':
case 'RI': case 'RI':
case 'FL': case 'FL':
case 'CA':
case 'ca':
gsStateObj.push([key, value]); gsStateObj.push([key, value]);
break; break;
case 'Font': case 'Font':
@ -428,8 +430,6 @@ var PartialEvaluator = (function partialEvaluator() {
case 'SA': case 'SA':
case 'BM': case 'BM':
case 'SMask': case 'SMask':
case 'CA':
case 'ca':
case 'AIS': case 'AIS':
case 'TK': case 'TK':
TODO('graphic state operator ' + key); TODO('graphic state operator ' + key);
@ -471,10 +471,10 @@ var PartialEvaluator = (function partialEvaluator() {
var widths = xref.fetchIfRef(dict.get('W')); var widths = xref.fetchIfRef(dict.get('W'));
if (widths) { if (widths) {
var start = 0, end = 0; var start = 0, end = 0;
for (var i = 0; i < widths.length; i++) { for (var i = 0, ii = widths.length; i < ii; i++) {
var code = widths[i]; var code = widths[i];
if (isArray(code)) { if (isArray(code)) {
for (var j = 0; j < code.length; j++) for (var j = 0, jj = code.length; j < jj; j++)
glyphsWidths[start++] = code[j]; glyphsWidths[start++] = code[j];
start = 0; start = 0;
} else if (start) { } else if (start) {
@ -515,7 +515,7 @@ var PartialEvaluator = (function partialEvaluator() {
// Set encoding 0 to later verify the font has an encoding // Set encoding 0 to later verify the font has an encoding
encoding[0] = { unicode: 0, width: 0 }; encoding[0] = { unicode: 0, width: 0 };
for (var j = 0; j < glyphsData.length; j++) { for (var j = 0, jj = glyphsData.length; j < jj; j++) {
var glyphID = (glyphsData[j++] << 8) | glyphsData[j]; var glyphID = (glyphsData[j++] << 8) | glyphsData[j];
if (glyphID == 0) if (glyphID == 0)
continue; continue;
@ -545,7 +545,7 @@ var PartialEvaluator = (function partialEvaluator() {
if (encoding.has('Differences')) { if (encoding.has('Differences')) {
var diffEncoding = encoding.get('Differences'); var diffEncoding = encoding.get('Differences');
var index = 0; var index = 0;
for (var j = 0; j < diffEncoding.length; j++) { for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
var data = diffEncoding[j]; var data = diffEncoding[j];
if (isNum(data)) if (isNum(data))
index = data; index = data;
@ -623,7 +623,7 @@ var PartialEvaluator = (function partialEvaluator() {
var beginArrayToken = {}; var beginArrayToken = {};
var cmap = cmapObj.getBytes(cmapObj.length); var cmap = cmapObj.getBytes(cmapObj.length);
for (var i = 0; i < cmap.length; i++) { for (var i = 0, ii = cmap.length; i < ii; i++) {
var byte = cmap[i]; var byte = cmap[i];
if (byte == 0x20 || byte == 0x0D || byte == 0x0A || if (byte == 0x20 || byte == 0x0D || byte == 0x0A ||
byte == 0x3C || byte == 0x5B || byte == 0x5D) { byte == 0x3C || byte == 0x5B || byte == 0x5D) {
@ -642,7 +642,7 @@ var PartialEvaluator = (function partialEvaluator() {
case 'endcidrange': case 'endcidrange':
case 'endbfrange': case 'endbfrange':
for (var j = 0; j < tokens.length; j += 3) { for (var j = 0, jj = tokens.length; j < jj; j += 3) {
var startRange = tokens[j]; var startRange = tokens[j];
var endRange = tokens[j + 1]; var endRange = tokens[j + 1];
var code = tokens[j + 2]; var code = tokens[j + 2];
@ -657,7 +657,7 @@ var PartialEvaluator = (function partialEvaluator() {
case 'endcidchar': case 'endcidchar':
case 'endbfchar': case 'endbfchar':
for (var j = 0; j < tokens.length; j += 2) { for (var j = 0, jj = tokens.length; j < jj; j += 2) {
var index = tokens[j]; var index = tokens[j];
var code = tokens[j + 1]; var code = tokens[j + 1];
var mapping = map[index] || {}; var mapping = map[index] || {};
@ -807,7 +807,7 @@ var PartialEvaluator = (function partialEvaluator() {
var encoding = {}; var encoding = {};
var widths = xref.fetchIfRef(dict.get('Widths')); var widths = xref.fetchIfRef(dict.get('Widths'));
if (widths) { if (widths) {
for (var i = 0, j = firstChar; i < widths.length; i++, j++) for (var i = 0, j = firstChar, ii = widths.length; i < ii; i++, j++)
glyphWidths[j] = widths[i]; glyphWidths[j] = widths[i];
defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0; defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
} else { } else {

View File

@ -393,7 +393,7 @@ var FontLoader = {
bind: function fontLoaderBind(fonts, callback) { bind: function fontLoaderBind(fonts, callback) {
function checkFontsLoaded() { function checkFontsLoaded() {
for (var i = 0; i < objs.length; i++) { for (var i = 0, ii = objs.length; i < ii; i++) {
var fontObj = objs[i]; var fontObj = objs[i];
if (fontObj.loading) { if (fontObj.loading) {
return false; return false;
@ -409,7 +409,7 @@ var FontLoader = {
var rules = [], names = [], objs = []; var rules = [], names = [], objs = [];
for (var i = 0; i < fonts.length; i++) { for (var i = 0, ii = fonts.length; i < ii; i++) {
var font = fonts[i]; var font = fonts[i];
// If there is already a fontObj on the font, then it was loaded/attached // If there is already a fontObj on the font, then it was loaded/attached
@ -490,7 +490,7 @@ var FontLoader = {
'width: 10px; height: 10px;' + 'width: 10px; height: 10px;' +
'position: absolute; top: 0px; left: 0px;'); 'position: absolute; top: 0px; left: 0px;');
var html = ''; var html = '';
for (var i = 0; i < names.length; ++i) { for (var i = 0, ii = names.length; i < ii; ++i) {
html += '<span style="font-family:' + names[i] + '">Hi</span>'; html += '<span style="font-family:' + names[i] + '">Hi</span>';
} }
div.innerHTML = html; div.innerHTML = html;
@ -501,7 +501,7 @@ var FontLoader = {
'message', 'message',
function fontLoaderMessage(e) { function fontLoaderMessage(e) {
var fontNames = JSON.parse(e.data); var fontNames = JSON.parse(e.data);
for (var i = 0; i < objs.length; ++i) { for (var i = 0, ii = objs.length; i < ii; ++i) {
var font = objs[i]; var font = objs[i];
font.loading = false; font.loading = false;
} }
@ -517,13 +517,13 @@ var FontLoader = {
// pdfjsFontLoadFailed? // pdfjsFontLoadFailed?
var src = '<!DOCTYPE HTML><html><head>'; var src = '<!DOCTYPE HTML><html><head>';
src += '<style type="text/css">'; src += '<style type="text/css">';
for (var i = 0; i < rules.length; ++i) { for (var i = 0, ii = rules.length; i < ii; ++i) {
src += rules[i]; src += rules[i];
} }
src += '</style>'; src += '</style>';
src += '<script type="application/javascript">'; src += '<script type="application/javascript">';
var fontNamesArray = ''; var fontNamesArray = '';
for (var i = 0; i < names.length; ++i) { for (var i = 0, ii = names.length; i < ii; ++i) {
fontNamesArray += '"' + names[i] + '", '; fontNamesArray += '"' + names[i] + '", ';
} }
src += ' var fontNames=[' + fontNamesArray + '];\n'; src += ' var fontNames=[' + fontNamesArray + '];\n';
@ -531,7 +531,7 @@ var FontLoader = {
src += ' parent.postMessage(JSON.stringify(fontNames), "*");\n'; src += ' parent.postMessage(JSON.stringify(fontNames), "*");\n';
src += ' }'; src += ' }';
src += '</script></head><body>'; src += '</script></head><body>';
for (var i = 0; i < names.length; ++i) { for (var i = 0, ii = names.length; i < ii; ++i) {
src += '<p style="font-family:\'' + names[i] + '\'">Hi</p>'; src += '<p style="font-family:\'' + names[i] + '\'">Hi</p>';
} }
src += '</body></html>'; src += '</body></html>';
@ -673,7 +673,7 @@ var UnicodeRanges = [
]; ];
function getUnicodeRangeFor(value) { function getUnicodeRangeFor(value) {
for (var i = 0; i < UnicodeRanges.length; i++) { for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
var range = UnicodeRanges[i]; var range = UnicodeRanges[i];
if (value >= range.begin && value < range.end) if (value >= range.begin && value < range.end)
return i; return i;
@ -782,7 +782,7 @@ var Font = (function Font() {
function stringToArray(str) { function stringToArray(str) {
var array = []; var array = [];
for (var i = 0; i < str.length; ++i) for (var i = 0, ii = str.length; i < ii; ++i)
array[i] = str.charCodeAt(i); array[i] = str.charCodeAt(i);
return array; return array;
@ -790,7 +790,7 @@ var Font = (function Font() {
function arrayToString(arr) { function arrayToString(arr) {
var str = ''; var str = '';
for (var i = 0; i < arr.length; ++i) for (var i = 0, ii = arr.length; i < ii; ++i)
str += String.fromCharCode(arr[i]); str += String.fromCharCode(arr[i]);
return str; return str;
@ -1116,11 +1116,11 @@ var Font = (function Font() {
// Mac want 1-byte per character strings while Windows want // Mac want 1-byte per character strings while Windows want
// 2-bytes per character, so duplicate the names table // 2-bytes per character, so duplicate the names table
var stringsUnicode = []; var stringsUnicode = [];
for (var i = 0; i < strings.length; i++) { for (var i = 0, ii = strings.length; i < ii; i++) {
var str = strings[i]; var str = strings[i];
var strUnicode = ''; var strUnicode = '';
for (var j = 0; j < str.length; j++) for (var j = 0, jj = str.length; j < jj; j++)
strUnicode += string16(str.charCodeAt(j)); strUnicode += string16(str.charCodeAt(j));
stringsUnicode.push(strUnicode); stringsUnicode.push(strUnicode);
} }
@ -1138,9 +1138,9 @@ var Font = (function Font() {
// Build the name records field // Build the name records field
var strOffset = 0; var strOffset = 0;
for (var i = 0; i < platforms.length; i++) { for (var i = 0, ii = platforms.length; i < ii; i++) {
var strs = names[i]; var strs = names[i];
for (var j = 0; j < strs.length; j++) { for (var j = 0, jj = strs.length; j < jj; j++) {
var str = strs[j]; var str = strs[j];
var nameRecord = var nameRecord =
platforms[i] + // platform ID platforms[i] + // platform ID
@ -1258,7 +1258,7 @@ var Font = (function Font() {
string32(table.offset); string32(table.offset);
} }
for (var i = 0; i < data.length; i++) for (var i = 0, ii = data.length; i < ii; i++)
cmap.data[i] = data.charCodeAt(i); cmap.data[i] = data.charCodeAt(i);
} }
@ -1345,7 +1345,7 @@ var Font = (function Font() {
if (numMissing > 0) { if (numMissing > 0) {
font.pos = (font.start ? font.start : 0) + metrics.offset; font.pos = (font.start ? font.start : 0) + metrics.offset;
var entries = ''; var entries = '';
for (var i = 0; i < hmtx.length; i++) for (var i = 0, ii = hmtx.length; i < ii; i++)
entries += String.fromCharCode(font.getByte()); entries += String.fromCharCode(font.getByte());
for (var i = 0; i < numMissing; i++) for (var i = 0; i < numMissing; i++)
entries += '\x00\x00'; entries += '\x00\x00';
@ -1549,18 +1549,18 @@ var Font = (function Font() {
}); });
// rewrite the tables but tweak offsets // rewrite the tables but tweak offsets
for (var i = 0; i < tables.length; i++) { for (var i = 0, ii = tables.length; i < ii; i++) {
var table = tables[i]; var table = tables[i];
var data = []; var data = [];
var tableData = table.data; var tableData = table.data;
for (var j = 0; j < tableData.length; j++) for (var j = 0, jj = tableData.length; j < jj; j++)
data.push(tableData[j]); data.push(tableData[j]);
createTableEntry(ttf, table.tag, data); createTableEntry(ttf, table.tag, data);
} }
// Add the table datas // Add the table datas
for (var i = 0; i < tables.length; i++) { for (var i = 0, ii = tables.length; i < ii; i++) {
var table = tables[i]; var table = tables[i];
var tableData = table.data; var tableData = table.data;
ttf.file += arrayToString(tableData); ttf.file += arrayToString(tableData);
@ -1575,7 +1575,7 @@ var Font = (function Font() {
convert: function font_convert(fontName, font, properties) { convert: function font_convert(fontName, font, properties) {
function isFixedPitch(glyphs) { function isFixedPitch(glyphs) {
for (var i = 0; i < glyphs.length - 1; i++) { for (var i = 0, ii = glyphs.length - 1; i < ii; i++) {
if (glyphs[i] != glyphs[i + 1]) if (glyphs[i] != glyphs[i + 1])
return false; return false;
} }
@ -1657,7 +1657,7 @@ var Font = (function Font() {
// Horizontal metrics // Horizontal metrics
'hmtx': (function fontFieldsHmtx() { 'hmtx': (function fontFieldsHmtx() {
var hmtx = '\x00\x00\x00\x00'; // Fake .notdef var hmtx = '\x00\x00\x00\x00'; // Fake .notdef
for (var i = 0; i < charstrings.length; i++) { for (var i = 0, ii = charstrings.length; i < ii; i++) {
hmtx += string16(charstrings[i].width) + string16(0); hmtx += string16(charstrings[i].width) + string16(0);
} }
return stringToArray(hmtx); return stringToArray(hmtx);
@ -1729,8 +1729,8 @@ var Font = (function Font() {
} }
encoding[0] = { unicode: 0, width: 0 }; encoding[0] = { unicode: 0, width: 0 };
var glyph = 1, i, j, k; var glyph = 1, i, j, k, cidLength, ii;
for (i = 0; i < cidToUnicode.length; ++i) { for (i = 0, ii = cidToUnicode.length; i < ii; ++i) {
var unicode = cidToUnicode[i]; var unicode = cidToUnicode[i];
var width; var width;
if (isArray(unicode)) { if (isArray(unicode)) {
@ -1787,12 +1787,11 @@ var Font = (function Font() {
var url = ('url(data:' + this.mimetype + ';base64,' + var url = ('url(data:' + this.mimetype + ';base64,' +
window.btoa(data) + ');'); window.btoa(data) + ');');
var rule = "@font-face { font-family:'" + fontName + "';src:" + url + '}'; var rule = "@font-face { font-family:'" + fontName + "';src:" + url + '}';
var styleSheet = document.styleSheets[0];
if (!styleSheet) { document.documentElement.firstChild.appendChild(
document.documentElement.firstChild.appendChild( document.createElement('style'));
document.createElement('style'));
styleSheet = document.styleSheets[0]; var styleSheet = document.styleSheets[document.styleSheets.length - 1];
}
styleSheet.insertRule(rule, styleSheet.cssRules.length); styleSheet.insertRule(rule, styleSheet.cssRules.length);
return rule; return rule;
@ -1844,7 +1843,7 @@ var Font = (function Font() {
} }
} }
else { else {
for (var i = 0; i < chars.length; ++i) { for (var i = 0, ii = chars.length; i < ii; ++i) {
var charcode = chars.charCodeAt(i); var charcode = chars.charCodeAt(i);
var glyph = encoding[charcode]; var glyph = encoding[charcode];
if ('undefined' == typeof(glyph)) { if ('undefined' == typeof(glyph)) {
@ -2142,7 +2141,7 @@ var Type1Parser = function type1Parser() {
count++; count++;
var array = str.substr(start, count).split(' '); var array = str.substr(start, count).split(' ');
for (var i = 0; i < array.length; i++) for (var i = 0, ii = array.length; i < ii; i++)
array[i] = parseFloat(array[i] || 0); array[i] = parseFloat(array[i] || 0);
return array; return array;
} }
@ -2167,7 +2166,7 @@ var Type1Parser = function type1Parser() {
this.extractFontProgram = function t1_extractFontProgram(stream) { this.extractFontProgram = function t1_extractFontProgram(stream) {
var eexec = decrypt(stream, kEexecEncryptionKey, 4); var eexec = decrypt(stream, kEexecEncryptionKey, 4);
var eexecStr = ''; var eexecStr = '';
for (var i = 0; i < eexec.length; i++) for (var i = 0, ii = eexec.length; i < ii; i++)
eexecStr += String.fromCharCode(eexec[i]); eexecStr += String.fromCharCode(eexec[i]);
var glyphsSection = false, subrsSection = false; var glyphsSection = false, subrsSection = false;
@ -2291,7 +2290,7 @@ var Type1Parser = function type1Parser() {
this.extractFontHeader = function t1_extractFontHeader(stream, properties) { this.extractFontHeader = function t1_extractFontHeader(stream, properties) {
var headerString = ''; var headerString = '';
for (var i = 0; i < stream.length; i++) for (var i = 0, ii = stream.length; i < ii; i++)
headerString += String.fromCharCode(stream[i]); headerString += String.fromCharCode(stream[i]);
var token = ''; var token = '';
@ -2318,7 +2317,7 @@ var Type1Parser = function type1Parser() {
var matrix = readNumberArray(headerString, i + 1); var matrix = readNumberArray(headerString, i + 1);
// The FontMatrix is in unitPerEm, so make it pixels // The FontMatrix is in unitPerEm, so make it pixels
for (var j = 0; j < matrix.length; j++) for (var j = 0, jj = matrix.length; j < jj; j++)
matrix[j] *= 1000; matrix[j] *= 1000;
// Make the angle into the right direction // Make the angle into the right direction
@ -2479,7 +2478,7 @@ CFF.prototype = {
} }
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
for (var j = 0; j < objects[i].length; j++) for (var j = 0, jj = objects[i].length; j < jj; j++)
data += isByte ? String.fromCharCode(objects[i][j] & 0xFF) : data += isByte ? String.fromCharCode(objects[i][j] & 0xFF) :
objects[i][j]; objects[i][j];
} }
@ -2507,7 +2506,7 @@ CFF.prototype = {
var charstrings = []; var charstrings = [];
var missings = []; var missings = [];
for (var i = 0; i < glyphs.length; i++) { for (var i = 0, ii = glyphs.length; i < ii; i++) {
var glyph = glyphs[i]; var glyph = glyphs[i];
var mapping = properties.glyphs[glyph.glyph]; var mapping = properties.glyphs[glyph.glyph];
if (!mapping) { if (!mapping) {
@ -2597,6 +2596,7 @@ CFF.prototype = {
}, },
flattenCharstring: function flattenCharstring(charstring, map) { flattenCharstring: function flattenCharstring(charstring, map) {
// charstring changes size - can't cache .length in loop
for (var i = 0; i < charstring.length; i++) { for (var i = 0; i < charstring.length; i++) {
var command = charstring[i]; var command = charstring[i];
if (command.charAt) { if (command.charAt) {
@ -2641,7 +2641,7 @@ CFF.prototype = {
'\x1c\x00\x00\x10'; // Encoding '\x1c\x00\x00\x10'; // Encoding
var boundingBox = properties.bbox; var boundingBox = properties.bbox;
for (var i = 0; i < boundingBox.length; i++) for (var i = 0, ii = boundingBox.length; i < ii; i++)
dict += self.encodeNumber(boundingBox[i]); dict += self.encodeNumber(boundingBox[i]);
dict += '\x05'; // FontBBox; dict += '\x05'; // FontBBox;
@ -2731,7 +2731,7 @@ CFF.prototype = {
if (isArray(value)) { if (isArray(value)) {
data += self.encodeNumber(value[0]); data += self.encodeNumber(value[0]);
for (var i = 1; i < value.length; i++) for (var i = 1, ii = value.length; i < ii; i++)
data += self.encodeNumber(value[i] - value[i - 1]); data += self.encodeNumber(value[i] - value[i - 1]);
} else { } else {
data += self.encodeNumber(value); data += self.encodeNumber(value);
@ -2752,7 +2752,7 @@ CFF.prototype = {
var cff = []; var cff = [];
for (var index in fields) { for (var index in fields) {
var field = fields[index]; var field = fields[index];
for (var i = 0; i < field.length; i++) for (var i = 0, ii = field.length; i < ii; i++)
cff.push(field.charCodeAt(i)); cff.push(field.charCodeAt(i));
} }
@ -2849,7 +2849,7 @@ var Type2CFF = (function type2CFF() {
// create the mapping between charstring and glyph id // create the mapping between charstring and glyph id
var glyphIds = []; var glyphIds = [];
for (var i = 0; i < charstrings.length; i++) for (var i = 0, ii = charstrings.length; i < ii; i++)
glyphIds.push(charstrings[i].gid); glyphIds.push(charstrings[i].gid);
this.charstrings = charstrings; this.charstrings = charstrings;
@ -2867,7 +2867,7 @@ var Type2CFF = (function type2CFF() {
var charstrings = []; var charstrings = [];
var firstChar = properties.firstChar; var firstChar = properties.firstChar;
var glyphMap = {}; var glyphMap = {};
for (var i = 0; i < charsets.length; i++) { for (var i = 0, ii = charsets.length; i < ii; i++) {
var glyph = charsets[i]; var glyph = charsets[i];
for (var charcode in encoding) { for (var charcode in encoding) {
if (encoding[charcode] == i) if (encoding[charcode] == i)
@ -2876,7 +2876,7 @@ var Type2CFF = (function type2CFF() {
} }
var differences = properties.differences; var differences = properties.differences;
for (var i = 0; i < differences.length; ++i) { for (var i = 0, ii = differences.length; i < ii; ++i) {
var glyph = differences[i]; var glyph = differences[i];
if (!glyph) if (!glyph)
continue; continue;
@ -2887,7 +2887,7 @@ var Type2CFF = (function type2CFF() {
} }
var glyphs = properties.glyphs; var glyphs = properties.glyphs;
for (var i = 1; i < charsets.length; i++) { for (var i = 1, ii = charsets.length; i < ii; i++) {
var glyph = charsets[i]; var glyph = charsets[i];
var code = glyphMap[glyph] || 0; var code = glyphMap[glyph] || 0;
@ -2921,7 +2921,7 @@ var Type2CFF = (function type2CFF() {
// properties.glyphs[code] || properties.glyphs[glyph] // properties.glyphs[code] || properties.glyphs[glyph]
var nextUnusedUnicode = kCmapGlyphOffset + 0x0020; var nextUnusedUnicode = kCmapGlyphOffset + 0x0020;
var lastUnicode = charstrings[0].unicode, wasModified = false; var lastUnicode = charstrings[0].unicode, wasModified = false;
for (var i = 1; i < charstrings.length; ++i) { for (var i = 1, ii = charstrings.length; i < ii; ++i) {
if (lastUnicode != charstrings[i].unicode) { if (lastUnicode != charstrings[i].unicode) {
lastUnicode = charstrings[i].unicode; lastUnicode = charstrings[i].unicode;
continue; continue;
@ -2966,7 +2966,7 @@ var Type2CFF = (function type2CFF() {
var gid = 1; var gid = 1;
var baseEncoding = pos ? Encodings.ExpertEncoding.slice() : var baseEncoding = pos ? Encodings.ExpertEncoding.slice() :
Encodings.StandardEncoding.slice(); Encodings.StandardEncoding.slice();
for (var i = 0; i < charset.length; i++) { for (var i = 0, ii = charset.length; i < ii; i++) {
var index = baseEncoding.indexOf(charset[i]); var index = baseEncoding.indexOf(charset[i]);
if (index != -1) if (index != -1)
encoding[index] = gid++; encoding[index] = gid++;
@ -3117,16 +3117,16 @@ var Type2CFF = (function type2CFF() {
getStrings: function cff_getStrings(stringIndex) { getStrings: function cff_getStrings(stringIndex) {
function bytesToString(bytesArray) { function bytesToString(bytesArray) {
var str = ''; var str = '';
for (var i = 0, length = bytesArray.length; i < length; i++) for (var i = 0, ii = bytesArray.length; i < ii; i++)
str += String.fromCharCode(bytesArray[i]); str += String.fromCharCode(bytesArray[i]);
return str; return str;
} }
var stringArray = []; var stringArray = [];
for (var i = 0, length = CFFStrings.length; i < length; i++) for (var i = 0, ii = CFFStrings.length; i < ii; i++)
stringArray.push(CFFStrings[i]); stringArray.push(CFFStrings[i]);
for (var i = 0, length = stringIndex.length; i < length; i++) for (var i = 0, ii = stringIndex.length; i < ii; i++)
stringArray.push(bytesToString(stringIndex.get(i).data)); stringArray.push(bytesToString(stringIndex.get(i).data));
return stringArray; return stringArray;

View File

@ -13,7 +13,7 @@ var PDFFunction = (function pdfFunction() {
getSampleArray: function pdfFunctionGetSampleArray(size, outputSize, bps, getSampleArray: function pdfFunctionGetSampleArray(size, outputSize, bps,
str) { str) {
var length = 1; var length = 1;
for (var i = 0; i < size.length; i++) for (var i = 0, ii = size.length; i < ii; i++)
length *= size[i]; length *= size[i];
length *= outputSize; length *= outputSize;
@ -254,7 +254,7 @@ var PDFFunction = (function pdfFunction() {
var fnsIR = IR[4]; var fnsIR = IR[4];
var fns = []; var fns = [];
for (var i = 0; i < fnsIR.length; i++) { for (var i = 0, ii = fnsIR.length; i < ii; i++) {
fns.push(PDFFunction.fromIR(fnsIR[i])); fns.push(PDFFunction.fromIR(fnsIR[i]));
} }

View File

@ -178,7 +178,7 @@ var Catalog = (function catalogCatalog() {
var kids = pagesDict.get('Kids'); var kids = pagesDict.get('Kids');
assertWellFormed(isArray(kids), assertWellFormed(isArray(kids),
'page dictionary kids object is not an array'); 'page dictionary kids object is not an array');
for (var i = 0; i < kids.length; ++i) { for (var i = 0, ii = kids.length; i < ii; ++i) {
var kid = kids[i]; var kid = kids[i];
assertWellFormed(isRef(kid), assertWellFormed(isRef(kid),
'page dictionary kid is not a reference'); 'page dictionary kid is not a reference');
@ -490,12 +490,12 @@ var XRef = (function xRefXRef() {
position += token.length + 1; position += token.length + 1;
} }
// reading XRef streams // reading XRef streams
for (var i = 0; i < xrefStms.length; ++i) { for (var i = 0, ii = xrefStms.length; i < ii; ++i) {
this.readXRef(xrefStms[i]); this.readXRef(xrefStms[i]);
} }
// finding main trailer // finding main trailer
var dict; var dict;
for (var i = 0; i < trailers.length; ++i) { for (var i = 0, ii = trailers.length; i < ii; ++i) {
stream.pos = trailers[i]; stream.pos = trailers[i];
var parser = new Parser(new Lexer(stream), true); var parser = new Parser(new Lexer(stream), true);
var obj = parser.getObj(); var obj = parser.getObj();

View File

@ -4,12 +4,11 @@
var PDFJS = {}; var PDFJS = {};
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
'use strict'; 'use strict';
// Files are inserted below - see Makefile // Files are inserted below - see Makefile
/* PDFJSSCRIPT_INCLUDE_ALL */ /* PDFJSSCRIPT_INCLUDE_ALL */
})(); }).call((typeof window === 'undefined') ? this : window);

View File

@ -261,7 +261,7 @@ var Promise = (function promise() {
this.data = data; this.data = data;
var callbacks = this.callbacks; var callbacks = this.callbacks;
for (var i = 0; i < callbacks.length; i++) { for (var i = 0, ii = callbacks.length; i < ii; i++) {
callbacks[i].call(null, data); callbacks[i].call(null, data);
} }
}, },

View File

@ -43,10 +43,21 @@ MessageHandler.prototype = {
} }
}; };
var WorkerProcessorHandler = { var WorkerMessageHandler = {
setup: function wphSetup(handler) { setup: function wphSetup(handler) {
var pdfDoc = null; var pdfDoc = null;
handler.on('test', function wphSetupTest(data) {
handler.send('test', data instanceof Uint8Array);
});
handler.on('workerSrc', function wphSetupWorkerSrc(data) {
// In development, the `workerSrc` message is handled in the
// `worker_loader.js` file. In production the workerProcessHandler is
// called for this. This servers as a dummy to prevent calling an
// undefined action `workerSrc`.
});
handler.on('doc', function wphSetupDoc(data) { handler.on('doc', function wphSetupDoc(data) {
// Create only the model of the PDFDoc, which is enough for // Create only the model of the PDFDoc, which is enough for
// processing the content of the pdf. // processing the content of the pdf.
@ -75,7 +86,7 @@ var WorkerProcessorHandler = {
// Filter the dependecies for fonts. // Filter the dependecies for fonts.
var fonts = {}; var fonts = {};
for (var i = 0; i < dependency.length; i++) { for (var i = 0, ii = dependency.length; i < ii; i++) {
var dep = dependency[i]; var dep = dependency[i];
if (dep.indexOf('font_') == 0) { if (dep.indexOf('font_') == 0) {
fonts[dep] = true; fonts[dep] = true;
@ -176,8 +187,7 @@ var workerConsole = {
if (typeof window === 'undefined') { if (typeof window === 'undefined') {
globalScope.console = workerConsole; globalScope.console = workerConsole;
// Listen for messages from the main thread. var handler = new MessageHandler('worker_processor', this);
var handler = new MessageHandler('worker_processor', globalScope); WorkerMessageHandler.setup(handler);
WorkerProcessorHandler.setup(handler);
} }

View File

@ -3,22 +3,50 @@
'use strict'; 'use strict';
importScripts('../src/core.js'); function onMessageLoader(evt) {
importScripts('../src/util.js'); // Reset the `onmessage` function as it was only set to call
importScripts('../src/canvas.js'); // this function the first time a message is passed to the worker
importScripts('../src/obj.js'); // but shouldn't get called anytime afterwards.
importScripts('../src/function.js'); this.onmessage = null;
importScripts('../src/charsets.js');
importScripts('../src/cidmaps.js');
importScripts('../src/colorspace.js');
importScripts('../src/crypto.js');
importScripts('../src/evaluator.js');
importScripts('../src/fonts.js');
importScripts('../src/glyphlist.js');
importScripts('../src/image.js');
importScripts('../src/metrics.js');
importScripts('../src/parser.js');
importScripts('../src/pattern.js');
importScripts('../src/stream.js');
importScripts('../src/worker.js');
if (evt.data.action !== 'workerSrc') {
throw 'Worker expects first message to be `workerSrc`';
}
// Content of `PDFJS.workerSrc` as defined on the main thread.
var workerSrc = evt.data.data;
// Extract the directory that contains the source files to load.
// Assuming the source files have the same relative possition as the
// `workerSrc` file.
var dir = workerSrc.substring(0, workerSrc.lastIndexOf('/') + 1);
// List of files to include;
var files = [
'core.js',
'util.js',
'canvas.js',
'obj.js',
'function.js',
'charsets.js',
'cidmaps.js',
'colorspace.js',
'crypto.js',
'evaluator.js',
'fonts.js',
'glyphlist.js',
'image.js',
'metrics.js',
'parser.js',
'pattern.js',
'stream.js',
'worker.js'
];
// Load all the files.
for (var i = 0; i < files.length; i++) {
importScripts(dir + files[i]);
}
}
this.onmessage = onMessageLoader;

View File

@ -13,3 +13,5 @@
!simpletype3font.pdf !simpletype3font.pdf
!sizes.pdf !sizes.pdf
!close-path-bug.pdf !close-path-bug.pdf
!alphatrans.pdf

BIN
test/pdfs/alphatrans.pdf Normal file

Binary file not shown.

View File

@ -1 +1 @@
http://www.wrapon.com/docs/PIPEHEATCABLE.PDF https://wrap-on.com/docs/PIPEHEATCABLE.PDF

View File

@ -1,4 +1,4 @@
import json, platform, os, shutil, sys, subprocess, tempfile, threading, time, urllib, urllib2 import json, platform, os, shutil, sys, subprocess, tempfile, threading, time, urllib, urllib2, hashlib
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import SocketServer import SocketServer
from optparse import OptionParser from optparse import OptionParser
@ -316,6 +316,28 @@ def downloadLinkedPDFs(manifestList):
print 'done' print 'done'
def verifyPDFs(manifestList):
error = False
for item in manifestList:
f = item['file']
if os.access(f, os.R_OK):
fileMd5 = hashlib.md5(open(f).read()).hexdigest()
if 'md5' not in item:
print 'ERROR: Missing md5 for file "' + f + '".',
print 'Hash for current file is "' + fileMd5 + '"'
error = True
continue
md5 = item['md5']
if fileMd5 != md5:
print 'ERROR: MD5 of file "' + f + '" does not match file.',
print 'Expected "' + md5 + '" computed "' + fileMd5 + '"'
error = True
continue
else:
print 'ERROR: Unable to open file for reading "' + f + '".'
error = True
return not error
def setUp(options): def setUp(options):
# Only serve files from a pdf.js clone # Only serve files from a pdf.js clone
assert not ANAL or os.path.isfile('../src/pdf.js') and os.path.isdir('../.git') assert not ANAL or os.path.isfile('../src/pdf.js') and os.path.isdir('../.git')
@ -342,6 +364,9 @@ def setUp(options):
downloadLinkedPDFs(manifestList) downloadLinkedPDFs(manifestList)
if not verifyPDFs(manifestList):
raise Exception('ERROR: failed to verify pdfs.')
for b in testBrowsers: for b in testBrowsers:
State.taskResults[b.name] = { } State.taskResults[b.name] = { }
for item in manifestList: for item in manifestList:
@ -506,17 +531,17 @@ def maybeUpdateRefImages(options, browser):
print ' Yes! The references in tmp/ can be synced with ref/.' print ' Yes! The references in tmp/ can be synced with ref/.'
if options.reftest: if options.reftest:
startReftest(browser, options) startReftest(browser, options)
if options.noPrompts or not prompt('Would you like to update the master copy in ref/?'): if options.noPrompts or prompt('Would you like to update the master copy in ref/?'):
print ' OK, not updating.'
else:
sys.stdout.write(' Updating ref/ ... ') sys.stdout.write(' Updating ref/ ... ')
# XXX unclear what to do on errors here ... # XXX unclear what to do on errors here ...
# NB: do *NOT* pass --delete to rsync. That breaks this # NB: do *NOT* pass --delete to rsync. That breaks this
# entire scheme. # entire scheme.
subprocess.check_call(( 'rsync', '-arv', 'tmp/', 'ref/' )) subprocess.check_call(( 'rsync', '-arvq', 'tmp/', 'ref/' ))
print 'done' print 'done'
else:
print ' OK, not updating.'
def startReftest(browser, options): def startReftest(browser, options):
url = "http://%s:%s" % (SERVER_HOST, options.port) url = "http://%s:%s" % (SERVER_HOST, options.port)

View File

@ -1,151 +1,178 @@
[ [
{ "id": "tracemonkey-eq", { "id": "tracemonkey-eq",
"file": "pdfs/tracemonkey.pdf", "file": "pdfs/tracemonkey.pdf",
"md5": "9a192d8b1a7dc652a19835f6f08098bd",
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "tracemonkey-fbf", { "id": "tracemonkey-fbf",
"file": "pdfs/tracemonkey.pdf", "file": "pdfs/tracemonkey.pdf",
"md5": "9a192d8b1a7dc652a19835f6f08098bd",
"rounds": 2, "rounds": 2,
"type": "fbf" "type": "fbf"
}, },
{ "id": "html5-canvas-cheat-sheet-load", { "id": "html5-canvas-cheat-sheet-load",
"file": "pdfs/canvas.pdf", "file": "pdfs/canvas.pdf",
"md5": "59510028561daf62e00bf9f6f066b033",
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "intelisa-load", { "id": "intelisa-load",
"file": "pdfs/intelisa.pdf", "file": "pdfs/intelisa.pdf",
"md5": "f3ed5487d1afa34d8b77c0c734a95c79",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "pdfspec-load", { "id": "pdfspec-load",
"file": "pdfs/pdf.pdf", "file": "pdfs/pdf.pdf",
"md5": "dbdb23c939d2be09b43126c3c56060c7",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "shavian-load", { "id": "shavian-load",
"file": "pdfs/shavian.pdf", "file": "pdfs/shavian.pdf",
"md5": "4fabf0a03e82693007435020bc446f9b",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "sizes", { "id": "sizes",
"file": "pdfs/sizes.pdf", "file": "pdfs/sizes.pdf",
"md5": "c101ba7b44aee36048e1ac7b98f302ea",
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "openweb-cover", { "id": "openweb-cover",
"file": "pdfs/openweb_tm-PRINT.pdf", "file": "pdfs/openweb_tm-PRINT.pdf",
"md5": "53f611dfc19ddfb50554c21c4af465c0",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "plusminus", { "id": "plusminus",
"file": "pdfs/Test-plusminus.pdf", "file": "pdfs/Test-plusminus.pdf",
"md5": "1ec7ade5b95ac9aaba3a618af28d34c7",
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "openoffice-pdf", { "id": "openoffice-pdf",
"file": "pdfs/DiwanProfile.pdf", "file": "pdfs/DiwanProfile.pdf",
"md5": "55d0c6a1a6d26c9ec9dcecaa7a471e0e",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "openofficecidtruetype-pdf", { "id": "openofficecidtruetype-pdf",
"file": "pdfs/arial_unicode_en_cidfont.pdf", "file": "pdfs/arial_unicode_en_cidfont.pdf",
"md5": "03591cdf20214fb0b2dd5e5c3dd32d8c",
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "openofficearabiccidtruetype-pdf", { "id": "openofficearabiccidtruetype-pdf",
"file": "pdfs/arial_unicode_ab_cidfont.pdf", "file": "pdfs/arial_unicode_ab_cidfont.pdf",
"md5": "35090fa7d29e7196ae3421812e554988",
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "arabiccidtruetype-pdf", { "id": "arabiccidtruetype-pdf",
"file": "pdfs/ArabicCIDTrueType.pdf", "file": "pdfs/ArabicCIDTrueType.pdf",
"md5": "d66dbd18bdb572d3ac8b88b32de2ece6",
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "complexttffont-pdf", { "id": "complexttffont-pdf",
"file": "pdfs/complex_ttf_font.pdf", "file": "pdfs/complex_ttf_font.pdf",
"md5": "76de93f9116b01b693bf8583b3e76d91",
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "thuluthfont-pdf", { "id": "thuluthfont-pdf",
"file": "pdfs/ThuluthFeatures.pdf", "file": "pdfs/ThuluthFeatures.pdf",
"md5": "b7e18bf7a3d6a9c82aefa12d721072fc",
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "wnv_chinese-pdf", { "id": "wnv_chinese-pdf",
"file": "pdfs/wnv_chinese.pdf", "file": "pdfs/wnv_chinese.pdf",
"md5": "db682638e68391125e8982d3c984841e",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "i9-pdf", { "id": "i9-pdf",
"file": "pdfs/i9.pdf", "file": "pdfs/i9.pdf",
"md5": "ba7cd54fdff083bb389295bc0415f6c5",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "hmm-pdf", { "id": "hmm-pdf",
"file": "pdfs/hmm.pdf", "file": "pdfs/hmm.pdf",
"md5": "e08467e60101ee5f4a59716e86db6dc9",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "rotation", { "id": "rotation",
"file": "pdfs/rotation.pdf", "file": "pdfs/rotation.pdf",
"md5": "4fb25ada00ce7528569d9791c14decf5",
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "ecma262-pdf", { "id": "ecma262-pdf",
"file": "pdfs/ecma262.pdf", "file": "pdfs/ecma262.pdf",
"md5": "763ead98f535578842891e5574e0af0f",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "jai-pdf", { "id": "jai-pdf",
"file": "pdfs/jai.pdf", "file": "pdfs/jai.pdf",
"md5": "1f5dd128c3757420a881a155f2f8ace3",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "cable", { "id": "cable",
"file": "pdfs/cable.pdf", "file": "pdfs/cable.pdf",
"md5": "09a41b9a759d60c698228224ab85b46d",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "pdkids", { "id": "pdkids",
"file": "pdfs/pdkids.pdf", "file": "pdfs/pdkids.pdf",
"md5": "278982bf016dbe46d2066f9245d9b3e6",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "artofwar", { "id": "artofwar",
"file": "pdfs/artofwar.pdf", "file": "pdfs/artofwar.pdf",
"md5": "7bdd51c327b74f1f7abdd90eedb2f912",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "wdsg_fitc", { "id": "wdsg_fitc",
"file": "pdfs/wdsg_fitc.pdf", "file": "pdfs/wdsg_fitc.pdf",
"md5": "5bb1c2b83705d4cdfc43197ee74f07f9",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "unix01", { "id": "unix01",
"file": "pdfs/unix01.pdf", "file": "pdfs/unix01.pdf",
"md5": "2742999f0bf9b9c035dbb0736096e220",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "fit11-talk", { "id": "fit11-talk",
"file": "pdfs/fit11-talk.pdf", "file": "pdfs/fit11-talk.pdf",
"md5": "eb7b224107205db4fea9f7df0185f77d",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"skipPages": [12,31], "skipPages": [12,31],
@ -153,48 +180,56 @@
}, },
{ "id": "fips197", { "id": "fips197",
"file": "pdfs/fips197.pdf", "file": "pdfs/fips197.pdf",
"md5": "374800cf78ce4b4abd02cd10a856b57f",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "txt2pdf", { "id": "txt2pdf",
"file": "pdfs/txt2pdf.pdf", "file": "pdfs/txt2pdf.pdf",
"md5": "02cefa0f5e8d96313bb05163b2f88c8c",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "f1040", { "id": "f1040",
"file": "pdfs/f1040.pdf", "file": "pdfs/f1040.pdf",
"md5": "7323b50c6d28d959b8b4b92c469b2469",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "hudsonsurvey", { "id": "hudsonsurvey",
"file": "pdfs/hudsonsurvey.pdf", "file": "pdfs/hudsonsurvey.pdf",
"md5": "bf0e6576a7b6c2fe7485bce1b78e006f",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "extgstate", { "id": "extgstate",
"file": "pdfs/extgstate.pdf", "file": "pdfs/extgstate.pdf",
"md5": "001bb4ec04463a01d93aad748361f049",
"link": false, "link": false,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "usmanm-bad", { "id": "usmanm-bad",
"file": "pdfs/usmanm-bad.pdf", "file": "pdfs/usmanm-bad.pdf",
"md5": "38afb822433aaf07fc8f54807cd4f61a",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "vesta-bad", { "id": "vesta-bad",
"file": "pdfs/vesta.pdf", "file": "pdfs/vesta.pdf",
"md5": "0afebc109b7c17b95619ea3fab5eafe6",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "load" "type": "load"
}, },
{ "id": "ibwa-bad", { "id": "ibwa-bad",
"file": "pdfs/ibwa-bad.pdf", "file": "pdfs/ibwa-bad.pdf",
"md5": "6ca059d32b74ac2688ae06f727fee755",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"skipPages": [ 16 ], "skipPages": [ 16 ],
@ -202,24 +237,35 @@
}, },
{ "id": "tcpdf_033", { "id": "tcpdf_033",
"file": "pdfs/tcpdf_033.pdf", "file": "pdfs/tcpdf_033.pdf",
"md5": "861294df58d185aae80919173f2732ff",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "pal-o47", { "id": "pal-o47",
"file": "pdfs/pal-o47.pdf", "file": "pdfs/pal-o47.pdf",
"md5": "81ae15e539e89f0f0b41169d923b611b",
"link": true, "link": true,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "simpletype3font", { "id": "simpletype3font",
"file": "pdfs/simpletype3font.pdf", "file": "pdfs/simpletype3font.pdf",
"md5": "b374c7543920840c61999e9e86939f99",
"link": false, "link": false,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "close-path-bug", { "id": "close-path-bug",
"file": "pdfs/close-path-bug.pdf", "file": "pdfs/close-path-bug.pdf",
"md5": "48dd17ef58393857d2d038d33699cac5",
"rounds": 1,
"type": "eq"
},
{ "id": "alphatrans",
"file": "pdfs/alphatrans.pdf",
"md5": "5ca2d3da0c5f20b3a5a14e895ad24b65",
"link": false,
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
} }

View File

@ -3,25 +3,29 @@
<head> <head>
<title>pdf.js test slave</title> <title>pdf.js test slave</title>
<style type="text/css"></style> <style type="text/css"></style>
<script type="text/javascript" src="/src/core.js"></script> <script type="text/javascript" src="/src/core.js"></script>
<script type="text/javascript" src="/src/util.js"></script> <script type="text/javascript" src="/src/util.js"></script>
<script type="text/javascript" src="/src/canvas.js"></script> <script type="text/javascript" src="/src/canvas.js"></script>
<script type="text/javascript" src="/src/obj.js"></script> <script type="text/javascript" src="/src/obj.js"></script>
<script type="text/javascript" src="/src/function.js"></script> <script type="text/javascript" src="/src/function.js"></script>
<script type="text/javascript" src="/src/charsets.js"></script> <script type="text/javascript" src="/src/charsets.js"></script>
<script type="text/javascript" src="/src/cidmaps.js"></script> <script type="text/javascript" src="/src/cidmaps.js"></script>
<script type="text/javascript" src="/src/colorspace.js"></script> <script type="text/javascript" src="/src/colorspace.js"></script>
<script type="text/javascript" src="/src/crypto.js"></script> <script type="text/javascript" src="/src/crypto.js"></script>
<script type="text/javascript" src="/src/evaluator.js"></script> <script type="text/javascript" src="/src/evaluator.js"></script>
<script type="text/javascript" src="/src/fonts.js"></script> <script type="text/javascript" src="/src/fonts.js"></script>
<script type="text/javascript" src="/src/glyphlist.js"></script> <script type="text/javascript" src="/src/glyphlist.js"></script>
<script type="text/javascript" src="/src/image.js"></script> <script type="text/javascript" src="/src/image.js"></script>
<script type="text/javascript" src="/src/metrics.js"></script> <script type="text/javascript" src="/src/metrics.js"></script>
<script type="text/javascript" src="/src/parser.js"></script> <script type="text/javascript" src="/src/parser.js"></script>
<script type="text/javascript" src="/src/pattern.js"></script> <script type="text/javascript" src="/src/pattern.js"></script>
<script type="text/javascript" src="/src/stream.js"></script> <script type="text/javascript" src="/src/stream.js"></script>
<script type="text/javascript" src="/src/worker.js"></script> <script type="text/javascript" src="/src/worker.js"></script>
<script type="text/javascript" src="driver.js"></script> <script type="text/javascript" src="driver.js"></script>
<script type="text/javascript">
PDFJS.workerSrc = '/src/worker_loader.js';
</script>
</head> </head>
<body> <body>

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset='utf-8'> <meta charset='utf-8'>
<title>andreasgal/pdf.js @ GitHub</title> <title>mozilla/pdf.js @ GitHub</title>
<style type="text/css"> <style type="text/css">
body { body {
@ -31,18 +31,18 @@
</head> </head>
<body> <body>
<a href="http://github.com/andreasgal/pdf.js"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a> <a href="http://github.com/mozilla/pdf.js"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<div id="container"> <div id="container">
<div class="download"> <div class="download">
<a href="http://github.com/andreasgal/pdf.js/zipball/master"> <a href="http://github.com/mozilla/pdf.js/zipball/master">
<img border="0" width="90" src="http://github.com/images/modules/download/zip.png"></a> <img border="0" width="90" src="http://github.com/images/modules/download/zip.png"></a>
<a href="http://github.com/andreasgal/pdf.js/tarball/master"> <a href="http://github.com/mozilla/pdf.js/tarball/master">
<img border="0" width="90" src="http://github.com/images/modules/download/tar.png"></a> <img border="0" width="90" src="http://github.com/images/modules/download/tar.png"></a>
</div> </div>
<h1><a href="http://github.com/andreasgal/pdf.js">pdf.js</a> <h1><a href="http://github.com/mozilla/pdf.js">pdf.js</a>
<span class="small">by <a href="http://github.com/andreasgal">andreasgal</a></span></h1> <span class="small">by <a href="http://github.com/andreasgal">andreasgal</a></span></h1>
<div class="description"> <div class="description">
@ -69,16 +69,16 @@
<h2>Download</h2> <h2>Download</h2>
<p> <p>
You can download this project in either You can download this project in either
<a href="http://github.com/andreasgal/pdf.js/zipball/master">zip</a> or <a href="http://github.com/mozilla/pdf.js/zipball/master">zip</a> or
<a href="http://github.com/andreasgal/pdf.js/tarball/master">tar</a> formats. <a href="http://github.com/mozilla/pdf.js/tarball/master">tar</a> formats.
</p> </p>
<p>You can also clone the project with <a href="http://git-scm.com">Git</a> <p>You can also clone the project with <a href="http://git-scm.com">Git</a>
by running: by running:
<pre>$ git clone git://github.com/andreasgal/pdf.js</pre> <pre>$ git clone git://github.com/mozilla/pdf.js</pre>
</p> </p>
<div class="footer"> <div class="footer">
get the source code on GitHub : <a href="http://github.com/andreasgal/pdf.js">andreasgal/pdf.js</a> get the source code on GitHub : <a href="http://github.com/mozilla/pdf.js">mozilla/pdf.js</a>
</div> </div>
</div> </div>

View File

@ -1,2 +1,6 @@
<!-- This snippet is used in production, see Makefile --> <!-- This snippet is used in production, see Makefile -->
<script type="text/javascript" src="../build/pdf.js"></script> <script type="text/javascript" src="../build/pdf.js"></script>
<script type="text/javascript">
// This specifies the location of the pdf.js file.
PDFJS.workerSrc = "../build/pdf.js";
</script>

View File

@ -18,11 +18,11 @@ body {
background: -moz-linear-gradient(center bottom, #eee 0%, #fff 100%); background: -moz-linear-gradient(center bottom, #eee 0%, #fff 100%);
background: -webkit-gradient(linear, left bottom, left top, color-stop(0.0, #ddd), color-stop(1.0, #fff)); background: -webkit-gradient(linear, left bottom, left top, color-stop(0.0, #ddd), color-stop(1.0, #fff));
border-bottom: 1px solid #666; border-bottom: 1px solid #666;
padding: 4px; padding: 3px;
position: fixed; position: fixed;
left: 0px; left: 0px;
top: 0px; top: 0px;
height: 40px; height: 24px;
width: 100%; width: 100%;
z-index: 1; z-index: 1;
white-space:nowrap; white-space:nowrap;
@ -33,22 +33,23 @@ body {
display: inline; display: inline;
border-left: 1px solid #d3d3d3; border-left: 1px solid #d3d3d3;
border-right: 1px solid #fff; border-right: 1px solid #fff;
height: 32px; height: 16px;
width:0px; width:0px;
margin: 4px; margin: 4px;
} }
#controls > a > img { #controls > a > img {
margin: 2px; margin: 4px;
height: 16px;
} }
#controls > button { #controls > button {
line-height: 32px; line-height: 16px;
} }
#controls > button > img { #controls > button > img {
width: 32px; width: 16px;
height: 32px; height: 16px;
} }
#controls > button[disabled] > img { #controls > button[disabled] > img {
@ -60,7 +61,7 @@ body {
} }
#fileInput { #fileInput {
line-height: 32px; line-height: 16px;
} }
span#info { span#info {

View File

@ -3,10 +3,10 @@
<head> <head>
<title>Simple pdf.js page viewer</title> <title>Simple pdf.js page viewer</title>
<link rel="stylesheet" href="viewer.css"/> <link rel="stylesheet" href="viewer.css"/>
<script type="text/javascript" src="compatibility.js"></script> <script type="text/javascript" src="compatibility.js"></script>
<!-- PDFJSSCRIPT_INCLUDE_BUILD --> <!-- PDFJSSCRIPT_INCLUDE_BUILD -->
<script type="text/javascript" src="../src/core.js"></script> <!-- PDFJSSCRIPT_REMOVE --> <script type="text/javascript" src="../src/core.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
<script type="text/javascript" src="../src/util.js"></script> <!-- PDFJSSCRIPT_REMOVE --> <script type="text/javascript" src="../src/util.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
<script type="text/javascript" src="../src/canvas.js"></script> <!-- PDFJSSCRIPT_REMOVE --> <script type="text/javascript" src="../src/canvas.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
@ -26,18 +26,20 @@
<script type="text/javascript" src="../src/stream.js"></script> <!-- PDFJSSCRIPT_REMOVE --> <script type="text/javascript" src="../src/stream.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
<script type="text/javascript" src="../src/worker.js"></script> <!-- PDFJSSCRIPT_REMOVE --> <script type="text/javascript" src="../src/worker.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
<script type="text/javascript">PDFJS.workerSrc = '../src/worker_loader.js';</script> <!-- PDFJSSCRIPT_REMOVE -->
<script type="text/javascript" src="viewer.js"></script> <script type="text/javascript" src="viewer.js"></script>
</head> </head>
<body> <body>
<div id="controls"> <div id="controls">
<button id="previous" onclick="PDFView.page--;" oncontextmenu="return false;"> <button id="previous" onclick="PDFView.page--;" oncontextmenu="return false;">
<img src="images/go-up.svg" align="top" height="32"/> <img src="images/go-up.svg" align="top" height="16"/>
Previous Previous
</button> </button>
<button id="next" onclick="PDFView.page++;" oncontextmenu="return false;"> <button id="next" onclick="PDFView.page++;" oncontextmenu="return false;">
<img src="images/go-down.svg" align="top" height="32"/> <img src="images/go-down.svg" align="top" height="16"/>
Next Next
</button> </button>
@ -51,10 +53,10 @@
<div class="separator"></div> <div class="separator"></div>
<button id="zoomOut" title="Zoom Out" onclick="PDFView.zoomOut();" oncontextmenu="return false;"> <button id="zoomOut" title="Zoom Out" onclick="PDFView.zoomOut();" oncontextmenu="return false;">
<img src="images/zoom-out.svg" align="top" height="32"/> <img src="images/zoom-out.svg" align="top" height="16"/>
</button> </button>
<button id="zoomIn" title="Zoom In" onclick="PDFView.zoomIn();" oncontextmenu="return false;"> <button id="zoomIn" title="Zoom In" onclick="PDFView.zoomIn();" oncontextmenu="return false;">
<img src="images/zoom-in.svg" align="top" height="32"/> <img src="images/zoom-in.svg" align="top" height="16"/>
</button> </button>
<div class="separator"></div> <div class="separator"></div>
@ -74,12 +76,12 @@
<div class="separator"></div> <div class="separator"></div>
<button id="print" onclick="window.print();" oncontextmenu="return false;"> <button id="print" onclick="window.print();" oncontextmenu="return false;">
<img src="images/document-print.svg" align="top" height="32"/> <img src="images/document-print.svg" align="top" height="16"/>
Print Print
</button> </button>
<button id="download" title="Download" onclick="PDFView.download();" oncontextmenu="return false;"> <button id="download" title="Download" onclick="PDFView.download();" oncontextmenu="return false;">
<img src="images/download.svg" align="top" height="32"/> <img src="images/download.svg" align="top" height="16"/>
Download Download
</button> </button>
@ -89,8 +91,8 @@
<div class="separator"></div> <div class="separator"></div>
<a href="#" id="viewBookmark" title="Current View (bookmark or copy the location)"> <a href="#" id="viewBookmark" title="Bookmark (or copy) current location">
<img src="images/bookmark.svg" alt="Bookmark" align="top" height="32"/> <img src="images/bookmark.svg" alt="Bookmark" align="top" height="16"/>
</a> </a>
<span id="info">--</span> <span id="info">--</span>
@ -106,15 +108,15 @@
</div> </div>
<div id="sidebarControls"> <div id="sidebarControls">
<button id="thumbsSwitch" title="Show Thumbnails" onclick="PDFView.switchSidebarView('thumbs')" data-selected> <button id="thumbsSwitch" title="Show Thumbnails" onclick="PDFView.switchSidebarView('thumbs')" data-selected>
<img src="images/nav-thumbs.svg" align="top" height="32" alt="Thumbs" /> <img src="images/nav-thumbs.svg" align="top" height="16" alt="Thumbs" />
</button> </button>
<button id="outlineSwitch" title="Show Document Outline" onclick="PDFView.switchSidebarView('outline')" disabled> <button id="outlineSwitch" title="Show Document Outline" onclick="PDFView.switchSidebarView('outline')" disabled>
<img src="images/nav-outline.svg" align="top" height="32" alt="Document Outline" /> <img src="images/nav-outline.svg" align="top" height="16" alt="Document Outline" />
</button> </button>
</div> </div>
</div> </div>
</div> </div>
<div id="loading">Loading... 0%</div> <div id="loading">Loading... 0%</div>
<div id="viewer"></div> <div id="viewer"></div>
</body> </body>