Merge branch 'master' of git://github.com/mozilla/pdf.js.git into forms-1

This commit is contained in:
notmasteryet 2011-11-12 15:20:31 -06:00
commit 1c18d054d5
28 changed files with 557 additions and 371 deletions

View File

@ -4,8 +4,9 @@ BUILD_TARGET := $(BUILD_DIR)/pdf.js
DEFAULT_BROWSERS := resources/browser_manifests/browser_manifest.json DEFAULT_BROWSERS := resources/browser_manifests/browser_manifest.json
DEFAULT_TESTS := test_manifest.json DEFAULT_TESTS := test_manifest.json
EXTENSION_SRC := ./extensions/firefox EXTENSION_SRC := ./extensions/
EXTENSION_NAME := pdf.js.xpi FIREFOX_EXTENSION_NAME := pdf.js.xpi
CHROME_EXTENSION_NAME := pdf.js.crx
all: bundle all: bundle
@ -125,7 +126,7 @@ browser-test:
# #
# <http://code.google.com/closure/utilities/docs/linter_howto.html> # <http://code.google.com/closure/utilities/docs/linter_howto.html>
SRC_DIRS := . src utils web test examples/helloworld extensions/firefox \ SRC_DIRS := . src utils web test examples/helloworld extensions/firefox \
extensions/firefox/components extensions/firefox/components extensions/chrome
GJSLINT_FILES = $(foreach DIR,$(SRC_DIRS),$(wildcard $(DIR)/*.js)) GJSLINT_FILES = $(foreach DIR,$(SRC_DIRS),$(wildcard $(DIR)/*.js))
lint: lint:
gjslint --nojsdoc $(GJSLINT_FILES) gjslint --nojsdoc $(GJSLINT_FILES)
@ -139,12 +140,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)/firefox/*.xpi $(GH_PAGES)/$(EXTENSION_SRC)/firefox/
@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;
@ -167,19 +167,7 @@ pages-repo: | $(BUILD_DIR)
@mkdir -p $(GH_PAGES)/web; @mkdir -p $(GH_PAGES)/web;
@mkdir -p $(GH_PAGES)/web/images; @mkdir -p $(GH_PAGES)/web/images;
@mkdir -p $(GH_PAGES)/build; @mkdir -p $(GH_PAGES)/build;
@mkdir -p $(GH_PAGES)/$(EXTENSION_SRC); @mkdir -p $(GH_PAGES)/$(EXTENSION_SRC)/firefox;
$(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
# # # #
@ -199,6 +187,8 @@ $(GH_PAGES)/$(EXTENSION_SRC)/%: $(EXTENSION_SRC)/%
# This target produce a restartless firefox extension containing a # This target produce a restartless firefox extension containing a
# copy of the pdf.js source. # copy of the pdf.js source.
CONTENT_DIR := content CONTENT_DIR := content
FIREFOX_CONTENT_DIR := $(EXTENSION_SRC)/firefox/$(CONTENT_DIR)/
CHROME_CONTENT_DIR := $(EXTENSION_SRC)/chrome/$(CONTENT_DIR)/
PDF_WEB_FILES = \ PDF_WEB_FILES = \
web/images \ web/images \
web/compatibility.js \ web/compatibility.js \
@ -208,16 +198,28 @@ PDF_WEB_FILES = \
$(NULL) $(NULL)
extension: | production extension: | production
# Copy a standalone version of pdf.js inside the content directory # Copy a standalone version of pdf.js inside the content directory
@rm -Rf $(EXTENSION_SRC)/$(CONTENT_DIR)/ @rm -Rf $(FIREFOX_CONTENT_DIR)
@mkdir -p $(EXTENSION_SRC)/$(CONTENT_DIR)/$(BUILD_DIR) @mkdir -p $(FIREFOX_CONTENT_DIR)/$(BUILD_DIR)
@mkdir -p $(EXTENSION_SRC)/$(CONTENT_DIR)/web @mkdir -p $(FIREFOX_CONTENT_DIR)/web
@cp $(BUILD_TARGET) $(EXTENSION_SRC)/$(CONTENT_DIR)/$(BUILD_DIR) @cp $(BUILD_TARGET) $(FIREFOX_CONTENT_DIR)/$(BUILD_DIR)
@cp -r $(PDF_WEB_FILES) $(EXTENSION_SRC)/$(CONTENT_DIR)/web/ @cp -r $(PDF_WEB_FILES) $(FIREFOX_CONTENT_DIR)/web/
@mv -f $(EXTENSION_SRC)/$(CONTENT_DIR)/web/viewer-production.html $(EXTENSION_SRC)/$(CONTENT_DIR)/web/viewer.html @mv -f $(FIREFOX_CONTENT_DIR)/web/viewer-production.html $(FIREFOX_CONTENT_DIR)/web/viewer.html
# Create the xpi # Create the xpi
@cd $(EXTENSION_SRC); zip -r $(EXTENSION_NAME) * @cd $(EXTENSION_SRC)/firefox; zip -r $(FIREFOX_EXTENSION_NAME) *
@echo "extension created: " $(EXTENSION_NAME) @echo "extension created: " $(FIREFOX_EXTENSION_NAME)
# Copy a standalone version of pdf.js inside the extension directory
@rm -Rf $(CHROME_CONTENT_DIR)
@mkdir -p $(CHROME_CONTENT_DIR)/$(BUILD_DIR)
@mkdir -p $(CHROME_CONTENT_DIR)/web
@cp $(BUILD_TARGET) $(CHROME_CONTENT_DIR)/$(BUILD_DIR)
@cp -r $(PDF_WEB_FILES) $(CHROME_CONTENT_DIR)/web/
@mv -f $(CHROME_CONTENT_DIR)/web/viewer-production.html $(CHROME_CONTENT_DIR)/web/viewer.html
# Create the crx
#TODO
# Make sure there's a build directory. # Make sure there's a build directory.

View File

@ -29,11 +29,15 @@ using the pdf.js API.
### Extension ### Extension
A Firefox extension is also available: An up-to-date Firefox extension is also available:
+ http://mozilla.github.com/pdf.js/extensions/firefox/pdf.js.xpi + 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. (The above link is updated upon every merge to our master branch).
For an experimental Chrome extension, get the code as explained below and issue `make extension`.
Then open Chrome with the flag `--enable-experimental-extension-apis`, go to `Tools > Extension`
and load the (unpackaged) extension from the directory `extensions/chrome`.
### Getting the code ### Getting the code

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

@ -0,0 +1,11 @@
{
"name": "uriloader@pdf.js",
"version": "0.1",
"description": "Read PDF Document",
"permissions": [
"experimental",
"http://*/*.pdf",
"file:///*/*.pdf"
],
"background_page": "pdfHandler.html"
}

View File

@ -0,0 +1,18 @@
<!doctype html>
<script>
chrome.experimental.webRequest.onBeforeRequest.addListener(
function(details) {
var viewerPage = 'content/web/viewer.html';
var url = chrome.extension.getURL(viewerPage) + '?file=' + details.url;
return { redirectUrl: url };
},
{
urls: [
"http://*/*.pdf",
"file://*/*.pdf",
],
types: [ "main_frame" ]
},
["blocking"]);
</script>

View File

@ -52,7 +52,7 @@ pdfContentHandler.prototype = {
} }
let targetUrl = aRequest.URI.spec; let targetUrl = aRequest.URI.spec;
if (targetUrl.indexOf('?pdfjs.action=download') >= 0) if (targetUrl.indexOf('#pdfjs.action=download') >= 0)
throw NS_ERROR_WONT_HANDLE_CONTENT; throw NS_ERROR_WONT_HANDLE_CONTENT;
aRequest.cancel(Cr.NS_BINDING_ABORTED); aRequest.cancel(Cr.NS_BINDING_ABORTED);

View File

@ -24,9 +24,9 @@ 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;
@ -125,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
@ -184,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];

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
@ -158,7 +157,6 @@ var Page = (function pagePage() {
var self = this; var self = this;
this.IRQueue = IRQueue; this.IRQueue = IRQueue;
var gfx = new CanvasGraphics(this.ctx, this.objs); var gfx = new CanvasGraphics(this.ctx, this.objs);
var startTime = Date.now();
var displayContinuation = function pageDisplayContinuation() { var displayContinuation = function pageDisplayContinuation() {
// Always defer call to display() to work around bug in // Always defer call to display() to work around bug in
@ -199,13 +197,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;
} }
@ -239,7 +237,6 @@ var Page = (function pagePage() {
var IRQueue = this.IRQueue; var IRQueue = this.IRQueue;
var self = this; var self = this;
var startTime = Date.now();
function next() { function next() {
startIdx = gfx.executeIRQueue(IRQueue, startIdx, next); startIdx = gfx.executeIRQueue(IRQueue, startIdx, next);
if (startIdx == length) { if (startIdx == length) {
@ -513,103 +510,144 @@ var PDFDoc = (function pdfDoc() {
this.objs = new PDFObjects(); this.objs = new PDFObjects();
this.pageCache = []; this.pageCache = [];
if (useWorker) {
var worker = new Worker('../src/worker_loader.js');
} else {
// If we don't use a worker, just post/sendMessage to the main thread.
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'); this.workerReadyPromise = new Promise('workerReady');
setTimeout(function pdfDocFontReadySetTimeout() {
processorHandler.send('doc', this.data); // If worker support isn't disabled explicit and the browser has worker
this.workerReadyPromise.resolve(true); // support, create a new web worker and test if it/the browser fullfills
}.bind(this)); // 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
try {
worker = new Worker(workerSrc);
} catch (e) {
// Some versions of FF can't create a worker on localhost, see:
// https://bugzilla.mozilla.org/show_bug.cgi?id=683280
globalScope.PDFJS.disableWorker = true;
this.setupFakeWorker();
return;
}
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 {
this.setupFakeWorker();
}
} }
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;
}, },
@ -617,7 +655,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));
}, },
@ -630,7 +668,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

@ -26,7 +26,6 @@ var ARCFourCipher = (function arcFourCipher() {
var a = this.a, b = this.b, s = this.s; var a = this.a, b = this.b, s = this.s;
var output = new Uint8Array(n); var output = new Uint8Array(n);
for (i = 0; i < n; ++i) { for (i = 0; i < n; ++i) {
var tmp;
a = (a + 1) & 0xFF; a = (a + 1) & 0xFF;
tmp = s[a]; tmp = s[a];
b = (b + tmp) & 0xFF; b = (b + tmp) & 0xFF;
@ -75,8 +74,8 @@ var calculateMD5 = (function calculateMD5() {
padded[i] = data[offset++]; padded[i] = data[offset++];
padded[i++] = 0x80; padded[i++] = 0x80;
n = paddedLength - 8; n = paddedLength - 8;
for (; i < n; ++i) while (i < n)
padded[i] = 0; padded[i++] = 0;
padded[i++] = (length << 3) & 0xFF; padded[i++] = (length << 3) & 0xFF;
padded[i++] = (length >> 5) & 0xFF; padded[i++] = (length >> 5) & 0xFF;
padded[i++] = (length >> 13) & 0xFF; padded[i++] = (length >> 13) & 0xFF;
@ -322,12 +321,12 @@ var AES128Cipher = (function aes128Cipher() {
state[10] = state[2]; state[6] = t; state[2] = u; state[10] = state[2]; state[6] = t; state[2] = u;
t = state[15]; u = state[11]; v = state[7]; state[15] = state[3]; t = state[15]; u = state[11]; v = state[7]; state[15] = state[3];
state[11] = t; state[7] = u; state[3] = v; state[11] = t; state[7] = u; state[3] = v;
// InvSubBytes for (j = 0; j < 16; ++j) {
for (j = 0; j < 16; ++j) // InvSubBytes
state[j] = inv_s[state[j]]; state[j] = inv_s[state[j]];
// AddRoundKey // AddRoundKey
for (j = 0; j < 16; ++j)
state[j] ^= key[j]; state[j] ^= key[j];
}
return state; return state;
} }
@ -338,7 +337,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 +365,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;
} }
@ -471,11 +470,11 @@ var CipherTransformFactory = (function cipherTransformFactory() {
cipher = new ARCFourCipher(encryptionKey); cipher = new ARCFourCipher(encryptionKey);
var checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i)); var checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
n = encryptionKey.length; n = encryptionKey.length;
var derrivedKey = new Uint8Array(n), k; var derivedKey = new Uint8Array(n), k;
for (j = 1; j <= 19; ++j) { for (j = 1; j <= 19; ++j) {
for (k = 0; k < n; ++k) for (k = 0; k < n; ++k)
derrivedKey[k] = encryptionKey[k] ^ j; derivedKey[k] = encryptionKey[k] ^ j;
cipher = new ARCFourCipher(derrivedKey); cipher = new ARCFourCipher(derivedKey);
checkData = cipher.encryptBlock(checkData); checkData = cipher.encryptBlock(checkData);
} }
} else { } else {

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]);
@ -145,12 +145,12 @@ var PartialEvaluator = (function partialEvaluator() {
var font = xref.fetchIfRef(fontRef); var font = xref.fetchIfRef(fontRef);
assertWellFormed(isDict(font)); assertWellFormed(isDict(font));
if (!font.translated) { if (!font.translated) {
font.translated = self.translateFont(font, xref, resources, handler, font.translated = self.translateFont(font, xref, resources,
uniquePrefix, dependency); dependency);
if (font.translated) { if (font.translated) {
// keep track of each font we translated so the caller can // keep track of each font we translated so the caller can
// load them asynchronously before calling display on a page // load them asynchronously before calling display on a page
loadedName = 'font_' + uniquePrefix + ++self.objIdCounter; loadedName = 'font_' + uniquePrefix + (++self.objIdCounter);
font.translated.properties.loadedName = loadedName; font.translated.properties.loadedName = loadedName;
font.loadedName = loadedName; font.loadedName = loadedName;
@ -180,7 +180,7 @@ var PartialEvaluator = (function partialEvaluator() {
var h = dict.get('Height', 'H'); var h = dict.get('Height', 'H');
if (image instanceof JpegStream) { if (image instanceof JpegStream) {
var objId = 'img_' + uniquePrefix + ++self.objIdCounter; var objId = 'img_' + uniquePrefix + (++self.objIdCounter);
handler.send('obj', [objId, 'JpegStream', image.getIR()]); handler.send('obj', [objId, 'JpegStream', image.getIR()]);
// Add the dependency on the image object. // Add the dependency on the image object.
@ -470,11 +470,11 @@ var PartialEvaluator = (function partialEvaluator() {
var glyphsWidths = {}; var glyphsWidths = {};
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;
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] || {};
@ -710,7 +710,8 @@ var PartialEvaluator = (function partialEvaluator() {
// special case for symbols // special case for symbols
var encoding = Encodings.symbolsEncoding.slice(); var encoding = Encodings.symbolsEncoding.slice();
for (var i = 0, n = encoding.length, j; i < n; i++) { for (var i = 0, n = encoding.length, j; i < n; i++) {
if (!(j = encoding[i])) j = encoding[i];
if (!j)
continue; continue;
map[i] = GlyphsUnicode[j] || 0; map[i] = GlyphsUnicode[j] || 0;
} }
@ -731,7 +732,7 @@ var PartialEvaluator = (function partialEvaluator() {
}, },
translateFont: function partialEvaluatorTranslateFont(dict, xref, resources, translateFont: function partialEvaluatorTranslateFont(dict, xref, resources,
queue, handler, uniquePrefix, dependency) { dependency) {
var baseDict = dict; var baseDict = dict;
var type = dict.get('Subtype'); var type = dict.get('Subtype');
assertWellFormed(isName(type), 'invalid font Subtype'); assertWellFormed(isName(type), 'invalid font Subtype');
@ -807,7 +808,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

@ -19,10 +19,10 @@ var Pattern = (function patternPattern() {
constructor.shadingFromIR = function pattern_shadingFromIR(ctx, raw) { constructor.shadingFromIR = function pattern_shadingFromIR(ctx, raw) {
return Shadings[raw[0]].fromIR(ctx, raw); return Shadings[raw[0]].fromIR(ctx, raw);
} };
constructor.parseShading = function pattern_shading(shading, matrix, constructor.parseShading = function pattern_shading(shading, matrix, xref,
xref, res, ctx) { res, ctx) {
var dict = isStream(shading) ? shading.dict : shading; var dict = isStream(shading) ? shading.dict : shading;
var type = dict.get('ShadingType'); var type = dict.get('ShadingType');
@ -116,17 +116,18 @@ Shadings.RadialAxial = (function radialAxialShading() {
p1 = Util.applyTransform(p1, userMatrix); p1 = Util.applyTransform(p1, userMatrix);
} }
var grad;
if (type == 2) if (type == 2)
var grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]); grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
else if (type == 3) else if (type == 3)
var grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1); grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
for (var i = 0, ii = colorStops.length; i < ii; ++i) { for (var i = 0, ii = colorStops.length; i < ii; ++i) {
var c = colorStops[i]; var c = colorStops[i];
grad.addColorStop(c[0], c[1]); grad.addColorStop(c[0], c[1]);
} }
return grad; return grad;
} };
constructor.prototype = { constructor.prototype = {
getIR: function radialAxialShadingGetIR() { getIR: function radialAxialShadingGetIR() {
@ -166,7 +167,7 @@ Shadings.Dummy = (function dummyShading() {
constructor.fromIR = function dummyShadingFromIR() { constructor.fromIR = function dummyShadingFromIR() {
return 'hotpink'; return 'hotpink';
} };
constructor.prototype = { constructor.prototype = {
getIR: function dummyShadingGetIR() { getIR: function dummyShadingGetIR() {
@ -242,9 +243,9 @@ var TilingPattern = (function tilingPattern() {
graphics.transform.apply(graphics, tmpTranslate); graphics.transform.apply(graphics, tmpTranslate);
if (bbox && isArray(bbox) && 4 == bbox.length) { if (bbox && isArray(bbox) && 4 == bbox.length) {
var bboxWidth = bbox[2] - bbox[0]; var bboxWidth = x1 - x0;
var bboxHeight = bbox[3] - bbox[1]; var bboxHeight = y1 - y0;
graphics.rectangle(bbox[0], bbox[1], bboxWidth, bboxHeight); graphics.rectangle(x0, y0, bboxWidth, bboxHeight);
graphics.clip(); graphics.clip();
graphics.endPath(); graphics.endPath();
} }
@ -264,7 +265,7 @@ var TilingPattern = (function tilingPattern() {
return [ return [
'TilingPattern', args, codeIR, matrix, bbox, xstep, ystep, paintType 'TilingPattern', args, codeIR, matrix, bbox, xstep, ystep, paintType
]; ];
} };
TilingPattern.prototype = { TilingPattern.prototype = {
getPattern: function tiling_getPattern() { getPattern: function tiling_getPattern() {

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

@ -7,6 +7,11 @@
'use strict'; 'use strict';
// Disable worker support for running test as
// https://github.com/mozilla/pdf.js/pull/764#issuecomment-2638944
// "firefox-bin: Fatal IO error 12 (Cannot allocate memory) on X server :1."
PDFJS.disableWorker = true;
var appPath, browser, canvas, currentTaskIdx, manifest, stdout; var appPath, browser, canvas, currentTaskIdx, manifest, stdout;
var inFlightRequests = 0; var inFlightRequests = 0;

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, 'rb').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,29 +237,34 @@
}, },
{ "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, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "alphatrans", { "id": "alphatrans",
"file": "pdfs/alphatrans.pdf", "file": "pdfs/alphatrans.pdf",
"md5": "5ca2d3da0c5f20b3a5a14e895ad24b65",
"link": false, "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

@ -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>

View File

@ -140,7 +140,7 @@ var PDFView = {
}, },
download: function pdfViewDownload() { download: function pdfViewDownload() {
window.open(this.url + '?pdfjs.action=download', '_parent'); window.open(this.url + '#pdfjs.action=download', '_parent');
}, },
navigateTo: function pdfViewNavigateTo(dest) { navigateTo: function pdfViewNavigateTo(dest) {