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_TESTS := test_manifest.json
EXTENSION_SRC := ./extensions/firefox
EXTENSION_NAME := pdf.js.xpi
EXTENSION_SRC := ./extensions/
FIREFOX_EXTENSION_NAME := pdf.js.xpi
CHROME_EXTENSION_NAME := pdf.js.crx
all: bundle
@ -125,7 +126,7 @@ browser-test:
#
# <http://code.google.com/closure/utilities/docs/linter_howto.html>
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))
lint:
gjslint --nojsdoc $(GJSLINT_FILES)
@ -139,12 +140,11 @@ lint:
# TODO: Use the Closure compiler to optimize the pdf.js files.
#
GH_PAGES = $(BUILD_DIR)/gh-pages
web: | production extension compiler pages-repo \
$(addprefix $(GH_PAGES)/, $(BUILD_TARGET)) \
$(addprefix $(GH_PAGES)/, $(wildcard web/*.*)) \
$(addprefix $(GH_PAGES)/, $(wildcard web/images/*.*)) \
$(addprefix $(GH_PAGES)/, $(wildcard $(EXTENSION_SRC)/*.xpi))
web: | production extension compiler pages-repo
@cp $(BUILD_TARGET) $(GH_PAGES)/$(BUILD_TARGET)
@cp -R web/* $(GH_PAGES)/web
@cp web/images/* $(GH_PAGES)/web/images
@cp $(EXTENSION_SRC)/firefox/*.xpi $(GH_PAGES)/$(EXTENSION_SRC)/firefox/
@cp $(GH_PAGES)/web/index.html.template $(GH_PAGES)/index.html;
@mv -f $(GH_PAGES)/web/viewer-production.html $(GH_PAGES)/web/viewer.html;
@cd $(GH_PAGES); git add -A;
@ -167,19 +167,7 @@ pages-repo: | $(BUILD_DIR)
@mkdir -p $(GH_PAGES)/web;
@mkdir -p $(GH_PAGES)/web/images;
@mkdir -p $(GH_PAGES)/build;
@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 $< $@
@mkdir -p $(GH_PAGES)/$(EXTENSION_SRC)/firefox;
# # make compiler
# #
@ -199,6 +187,8 @@ $(GH_PAGES)/$(EXTENSION_SRC)/%: $(EXTENSION_SRC)/%
# This target produce a restartless firefox extension containing a
# copy of the pdf.js source.
CONTENT_DIR := content
FIREFOX_CONTENT_DIR := $(EXTENSION_SRC)/firefox/$(CONTENT_DIR)/
CHROME_CONTENT_DIR := $(EXTENSION_SRC)/chrome/$(CONTENT_DIR)/
PDF_WEB_FILES = \
web/images \
web/compatibility.js \
@ -208,16 +198,28 @@ PDF_WEB_FILES = \
$(NULL)
extension: | production
# Copy a standalone version of pdf.js inside the content directory
@rm -Rf $(EXTENSION_SRC)/$(CONTENT_DIR)/
@mkdir -p $(EXTENSION_SRC)/$(CONTENT_DIR)/$(BUILD_DIR)
@mkdir -p $(EXTENSION_SRC)/$(CONTENT_DIR)/web
@cp $(BUILD_TARGET) $(EXTENSION_SRC)/$(CONTENT_DIR)/$(BUILD_DIR)
@cp -r $(PDF_WEB_FILES) $(EXTENSION_SRC)/$(CONTENT_DIR)/web/
@mv -f $(EXTENSION_SRC)/$(CONTENT_DIR)/web/viewer-production.html $(EXTENSION_SRC)/$(CONTENT_DIR)/web/viewer.html
@rm -Rf $(FIREFOX_CONTENT_DIR)
@mkdir -p $(FIREFOX_CONTENT_DIR)/$(BUILD_DIR)
@mkdir -p $(FIREFOX_CONTENT_DIR)/web
@cp $(BUILD_TARGET) $(FIREFOX_CONTENT_DIR)/$(BUILD_DIR)
@cp -r $(PDF_WEB_FILES) $(FIREFOX_CONTENT_DIR)/web/
@mv -f $(FIREFOX_CONTENT_DIR)/web/viewer-production.html $(FIREFOX_CONTENT_DIR)/web/viewer.html
# Create the xpi
@cd $(EXTENSION_SRC); zip -r $(EXTENSION_NAME) *
@echo "extension created: " $(EXTENSION_NAME)
@cd $(EXTENSION_SRC)/firefox; zip -r $(FIREFOX_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.

View File

@ -29,11 +29,15 @@ using the pdf.js API.
### 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
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

View File

@ -3,27 +3,33 @@
<head>
<!-- In production, only one script (pdf.js) is necessary -->
<script type="text/javascript" src="../../src/core.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/obj.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/cidmaps.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/evaluator.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/image.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/pattern.js"></script>
<script type="text/javascript" src="../../src/stream.js"></script>
<script type="text/javascript" src="../../src/worker.js"></script>
<!-- In production, change the content of PDFJS.workerSrc below -->
<script type="text/javascript" src="../../src/core.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/obj.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/cidmaps.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/evaluator.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/image.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/pattern.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>
</head>
</head>
<body>
<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;
if (targetUrl.indexOf('?pdfjs.action=download') >= 0)
if (targetUrl.indexOf('#pdfjs.action=download') >= 0)
throw NS_ERROR_WONT_HANDLE_CONTENT;
aRequest.cancel(Cr.NS_BINDING_ABORTED);

View File

@ -24,9 +24,9 @@ var CanvasExtraState = (function canvasExtraState() {
this.wordSpacing = 0;
this.textHScale = 1;
// Color spaces
this.fillColorSpace = new DeviceGrayCS;
this.fillColorSpace = new DeviceGrayCS();
this.fillColorSpaceObj = null;
this.strokeColorSpace = new DeviceGrayCS;
this.strokeColorSpace = new DeviceGrayCS();
this.strokeColorSpaceObj = null;
this.fillColorObj = null;
this.strokeColorObj = null;
@ -125,7 +125,7 @@ var CanvasGraphics = (function canvasGraphics() {
this[fnArray[i]].apply(this, argsArray[i]);
} else {
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];
// If the promise isn't resolved yet, add the continueCallback
@ -184,7 +184,7 @@ var CanvasGraphics = (function canvasGraphics() {
TODO('set flatness: ' + flatness);
},
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 key = state[0];
var value = state[1];

View File

@ -23,7 +23,7 @@ var ColorSpace = (function colorSpaceColorSpace() {
};
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)
return IR;
@ -31,12 +31,7 @@ var ColorSpace = (function colorSpaceColorSpace() {
};
constructor.fromIR = function colorSpaceFromIR(IR) {
var name;
if (isArray(IR)) {
name = IR[0];
} else {
name = IR;
}
var name = isArray(IR) ? IR[0] : IR;
switch (name) {
case 'DeviceGrayCS':
@ -46,33 +41,28 @@ var ColorSpace = (function colorSpaceColorSpace() {
case 'DeviceCmykCS':
return new DeviceCmykCS();
case 'PatternCS':
var baseCS = IR[1];
if (baseCS == null) {
return new PatternCS(null);
} else {
return new PatternCS(ColorSpace.fromIR(baseCS));
}
var basePatternCS = IR[1];
if (basePatternCS)
basePatternCS = ColorSpace.fromIR(basePatternCS);
return new PatternCS(basePatternCS);
case 'IndexedCS':
var baseCS = IR[1];
var baseIndexedCS = IR[1];
var hiVal = IR[2];
var lookup = IR[3];
return new IndexedCS(ColorSpace.fromIR(baseCS), hiVal, lookup);
return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
case 'SeparationCS':
var alt = IR[1];
var tintFnIR = IR[2];
return new SeparationCS(
ColorSpace.fromIR(alt),
PDFFunction.fromIR(tintFnIR)
);
return new SeparationCS(ColorSpace.fromIR(alt),
PDFFunction.fromIR(tintFnIR));
default:
error('Unkown name ' + name);
}
return null;
}
};
constructor.parseToIR = function colorSpaceParseToIR(cs, xref, res,
parseOnly) {
constructor.parseToIR = function colorSpaceParseToIR(cs, xref, res) {
if (isName(cs)) {
var colorSpaces = xref.fetchIfRef(res.get('ColorSpace'));
if (isDict(colorSpaces)) {
@ -83,9 +73,10 @@ var ColorSpace = (function colorSpaceColorSpace() {
}
cs = xref.fetchIfRef(cs);
var mode;
if (isName(cs)) {
var mode = cs.name;
mode = cs.name;
this.mode = mode;
switch (mode) {
@ -104,7 +95,7 @@ var ColorSpace = (function colorSpaceColorSpace() {
error('unrecognized colorspace ' + mode);
}
} else if (isArray(cs)) {
var mode = cs[0].name;
mode = cs[0].name;
this.mode = mode;
switch (mode) {
@ -133,15 +124,15 @@ var ColorSpace = (function colorSpaceColorSpace() {
return 'DeviceCmykCS';
break;
case 'Pattern':
var baseCS = cs[1];
if (baseCS)
baseCS = ColorSpace.parseToIR(baseCS, xref, res);
return ['PatternCS', baseCS];
var basePatternCS = cs[1];
if (basePatternCS)
basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
return ['PatternCS', basePatternCS];
case 'Indexed':
var baseCS = ColorSpace.parseToIR(cs[1], xref, res);
var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
var hiVal = cs[2] + 1;
var lookup = xref.fetchIfRef(cs[3]);
return ['IndexedCS', baseCS, hiVal, lookup];
return ['IndexedCS', baseIndexedCS, hiVal, lookup];
case 'Separation':
var alt = ColorSpace.parseToIR(cs[2], xref, res);
var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
@ -165,7 +156,6 @@ var SeparationCS = (function separationCS() {
this.name = 'Separation';
this.numComps = 1;
this.defaultColor = [1];
this.base = base;
this.tintFn = tintFn;
}
@ -179,12 +169,11 @@ var SeparationCS = (function separationCS() {
var tintFn = this.tintFn;
var base = this.base;
var scale = 1 / ((1 << bits) - 1);
var length = input.length;
var pos = 0;
var numComps = base.numComps;
var baseBuf = new Uint8Array(numComps * length);
for (var i = 0; i < length; ++i) {
var scaled = input[i] * scale;
var tinted = tintFn([scaled]);
@ -213,13 +202,13 @@ var IndexedCS = (function indexedCS() {
this.name = 'Indexed';
this.numComps = 1;
this.defaultColor = [0];
this.base = base;
var baseNumComps = base.numComps;
this.highVal = highVal;
var baseNumComps = base.numComps;
var length = baseNumComps * highVal;
var lookupArray = new Uint8Array(length);
if (isStream(lookup)) {
var bytes = lookup.getBytes(length);
lookupArray.set(bytes);
@ -235,7 +224,6 @@ var IndexedCS = (function indexedCS() {
constructor.prototype = {
getRgb: function indexcs_getRgb(color) {
var numComps = this.base.numComps;
var start = color[0] * numComps;
var c = [];
@ -249,9 +237,9 @@ var IndexedCS = (function indexedCS() {
var numComps = base.numComps;
var lookup = this.lookup;
var length = input.length;
var baseBuf = new Uint8Array(length * numComps);
var baseBufPos = 0;
for (var i = 0; i < length; ++i) {
var lookupPos = input[i] * numComps;
for (var j = 0; j < numComps; ++j) {
@ -294,7 +282,7 @@ var DeviceGrayCS = (function deviceGrayCS() {
})();
var DeviceRgbCS = (function deviceRgbCS() {
function constructor(bits) {
function constructor() {
this.name = 'DeviceRGB';
this.numComps = 3;
this.defaultColor = [0, 0, 0];
@ -337,41 +325,41 @@ var DeviceCmykCS = (function deviceCmykCS() {
r += 0.1373 * x;
g += 0.1216 * 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;
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;
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;
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;
x = c1 * m * y * k1; // 0 1 1 0
x = c1 * m * y * k1; // 0 1 1 0
r += 0.9294 * x;
g += 0.1098 * 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;
x = c * m1 * y1 * k1; // 1 0 0 0
x = c * m1 * y1 * k1; // 1 0 0 0
g += 0.6784 * 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;
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;
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;
x = c * m * y1 * k1; // 1 1 0 0
x = c * m * y1 * k1; // 1 1 0 0
r += 0.1804 * x;
g += 0.1922 * 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;
x = c * m * y * k1; // 1 1 1 0
x = c * m * y * k1; // 1 1 1 0
r += 0.2118 * x;
g += 0.2119 * 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 verbosity = WARNINGS;
var useWorker = false;
// The global PDFJS object exposes the API
// In production, it will be declared outside a global wrapper
@ -158,7 +157,6 @@ var Page = (function pagePage() {
var self = this;
this.IRQueue = IRQueue;
var gfx = new CanvasGraphics(this.ctx, this.objs);
var startTime = Date.now();
var displayContinuation = function pageDisplayContinuation() {
// Always defer call to display() to work around bug in
@ -199,13 +197,13 @@ var Page = (function pagePage() {
var pe = this.pe = new PartialEvaluator(
xref, handler, 'p' + this.pageNumber + '_');
var IRQueue = {};
return this.IRQueue = pe.getIRQueue(
content, resources, IRQueue, dependency);
return (this.IRQueue = pe.getIRQueue(content, resources, IRQueue,
dependency));
},
ensureFonts: function pageEnsureFonts(fonts, callback) {
// 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;
}
@ -239,7 +237,6 @@ var Page = (function pagePage() {
var IRQueue = this.IRQueue;
var self = this;
var startTime = Date.now();
function next() {
startIdx = gfx.executeIRQueue(IRQueue, startIdx, next);
if (startIdx == length) {
@ -513,103 +510,144 @@ var PDFDoc = (function pdfDoc() {
this.objs = new PDFObjects();
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 = {};
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));
// If worker support isn't disabled explicit and the browser has worker
// 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
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 = {
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() {
return this.pdf.numPages;
},
@ -617,7 +655,7 @@ var PDFDoc = (function pdfDoc() {
startRendering: function pdfDocStartRendering(page) {
// The worker might not be ready to receive the page request yet.
this.workerReadyPromise.then(function pdfDocStartRenderingThen() {
this.processorHandler.send('page_request', page.pageNumber + 1);
this.messageHandler.send('page_request', page.pageNumber + 1);
}.bind(this));
},
@ -630,7 +668,7 @@ var PDFDoc = (function pdfDoc() {
// to the CanvasGraphics and so on.
page.objs = this.objs;
page.pdf = this;
return this.pageCache[n] = page;
return (this.pageCache[n] = page);
},
destroy: function pdfDocDestroy() {

View File

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

View File

@ -123,7 +123,7 @@ var PartialEvaluator = (function partialEvaluator() {
function insertDependency(depList) {
fnArray.push('dependency');
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];
if (dependency.indexOf(dep) == -1) {
dependency.push(depList[i]);
@ -145,12 +145,12 @@ var PartialEvaluator = (function partialEvaluator() {
var font = xref.fetchIfRef(fontRef);
assertWellFormed(isDict(font));
if (!font.translated) {
font.translated = self.translateFont(font, xref, resources, handler,
uniquePrefix, dependency);
font.translated = self.translateFont(font, xref, resources,
dependency);
if (font.translated) {
// keep track of each font we translated so the caller can
// 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.loadedName = loadedName;
@ -180,7 +180,7 @@ var PartialEvaluator = (function partialEvaluator() {
var h = dict.get('Height', 'H');
if (image instanceof JpegStream) {
var objId = 'img_' + uniquePrefix + ++self.objIdCounter;
var objId = 'img_' + uniquePrefix + (++self.objIdCounter);
handler.send('obj', [objId, 'JpegStream', image.getIR()]);
// Add the dependency on the image object.
@ -470,11 +470,11 @@ var PartialEvaluator = (function partialEvaluator() {
var glyphsWidths = {};
var widths = xref.fetchIfRef(dict.get('W'));
if (widths) {
var start = 0, end = 0;
for (var i = 0; i < widths.length; i++) {
var start = 0;
for (var i = 0, ii = widths.length; i < ii; i++) {
var code = widths[i];
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];
start = 0;
} else if (start) {
@ -515,7 +515,7 @@ var PartialEvaluator = (function partialEvaluator() {
// Set encoding 0 to later verify the font has an encoding
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];
if (glyphID == 0)
continue;
@ -545,7 +545,7 @@ var PartialEvaluator = (function partialEvaluator() {
if (encoding.has('Differences')) {
var diffEncoding = encoding.get('Differences');
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];
if (isNum(data))
index = data;
@ -623,7 +623,7 @@ var PartialEvaluator = (function partialEvaluator() {
var beginArrayToken = {};
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];
if (byte == 0x20 || byte == 0x0D || byte == 0x0A ||
byte == 0x3C || byte == 0x5B || byte == 0x5D) {
@ -642,7 +642,7 @@ var PartialEvaluator = (function partialEvaluator() {
case 'endcidrange':
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 endRange = tokens[j + 1];
var code = tokens[j + 2];
@ -657,7 +657,7 @@ var PartialEvaluator = (function partialEvaluator() {
case 'endcidchar':
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 code = tokens[j + 1];
var mapping = map[index] || {};
@ -710,7 +710,8 @@ var PartialEvaluator = (function partialEvaluator() {
// special case for symbols
var encoding = Encodings.symbolsEncoding.slice();
for (var i = 0, n = encoding.length, j; i < n; i++) {
if (!(j = encoding[i]))
j = encoding[i];
if (!j)
continue;
map[i] = GlyphsUnicode[j] || 0;
}
@ -731,7 +732,7 @@ var PartialEvaluator = (function partialEvaluator() {
},
translateFont: function partialEvaluatorTranslateFont(dict, xref, resources,
queue, handler, uniquePrefix, dependency) {
dependency) {
var baseDict = dict;
var type = dict.get('Subtype');
assertWellFormed(isName(type), 'invalid font Subtype');
@ -807,7 +808,7 @@ var PartialEvaluator = (function partialEvaluator() {
var encoding = {};
var widths = xref.fetchIfRef(dict.get('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];
defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
} else {

View File

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

View File

@ -13,7 +13,7 @@ var PDFFunction = (function pdfFunction() {
getSampleArray: function pdfFunctionGetSampleArray(size, outputSize, bps,
str) {
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 *= outputSize;
@ -254,7 +254,7 @@ var PDFFunction = (function pdfFunction() {
var fnsIR = IR[4];
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]));
}

View File

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

View File

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

View File

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

View File

@ -261,7 +261,7 @@ var Promise = (function promise() {
this.data = data;
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);
}
},

View File

@ -43,10 +43,21 @@ MessageHandler.prototype = {
}
};
var WorkerProcessorHandler = {
var WorkerMessageHandler = {
setup: function wphSetup(handler) {
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) {
// Create only the model of the PDFDoc, which is enough for
// processing the content of the pdf.
@ -75,7 +86,7 @@ var WorkerProcessorHandler = {
// Filter the dependecies for 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];
if (dep.indexOf('font_') == 0) {
fonts[dep] = true;
@ -176,8 +187,7 @@ var workerConsole = {
if (typeof window === 'undefined') {
globalScope.console = workerConsole;
// Listen for messages from the main thread.
var handler = new MessageHandler('worker_processor', globalScope);
WorkerProcessorHandler.setup(handler);
var handler = new MessageHandler('worker_processor', this);
WorkerMessageHandler.setup(handler);
}

View File

@ -3,22 +3,50 @@
'use strict';
importScripts('../src/core.js');
importScripts('../src/util.js');
importScripts('../src/canvas.js');
importScripts('../src/obj.js');
importScripts('../src/function.js');
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');
function onMessageLoader(evt) {
// Reset the `onmessage` function as it was only set to call
// this function the first time a message is passed to the worker
// but shouldn't get called anytime afterwards.
this.onmessage = null;
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';
// 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 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
import SocketServer
from optparse import OptionParser
@ -316,6 +316,28 @@ def downloadLinkedPDFs(manifestList):
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):
# Only serve files from a pdf.js clone
assert not ANAL or os.path.isfile('../src/pdf.js') and os.path.isdir('../.git')
@ -342,6 +364,9 @@ def setUp(options):
downloadLinkedPDFs(manifestList)
if not verifyPDFs(manifestList):
raise Exception('ERROR: failed to verify pdfs.')
for b in testBrowsers:
State.taskResults[b.name] = { }
for item in manifestList:
@ -506,17 +531,17 @@ def maybeUpdateRefImages(options, browser):
print ' Yes! The references in tmp/ can be synced with ref/.'
if options.reftest:
startReftest(browser, options)
if options.noPrompts or not prompt('Would you like to update the master copy in ref/?'):
print ' OK, not updating.'
else:
if options.noPrompts or prompt('Would you like to update the master copy in ref/?'):
sys.stdout.write(' Updating ref/ ... ')
# XXX unclear what to do on errors here ...
# NB: do *NOT* pass --delete to rsync. That breaks this
# entire scheme.
subprocess.check_call(( 'rsync', '-arv', 'tmp/', 'ref/' ))
subprocess.check_call(( 'rsync', '-arvq', 'tmp/', 'ref/' ))
print 'done'
else:
print ' OK, not updating.'
def startReftest(browser, options):
url = "http://%s:%s" % (SERVER_HOST, options.port)

View File

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

View File

@ -3,25 +3,29 @@
<head>
<title>pdf.js test slave</title>
<style type="text/css"></style>
<script type="text/javascript" src="/src/core.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/obj.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/cidmaps.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/evaluator.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/image.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/pattern.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/core.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/obj.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/cidmaps.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/evaluator.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/image.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/pattern.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="driver.js"></script>
<script type="text/javascript">
PDFJS.workerSrc = '/src/worker_loader.js';
</script>
</head>
<body>

View File

@ -1,2 +1,6 @@
<!-- This snippet is used in production, see Makefile -->
<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: -webkit-gradient(linear, left bottom, left top, color-stop(0.0, #ddd), color-stop(1.0, #fff));
border-bottom: 1px solid #666;
padding: 4px;
padding: 3px;
position: fixed;
left: 0px;
top: 0px;
height: 40px;
height: 24px;
width: 100%;
z-index: 1;
white-space:nowrap;
@ -33,22 +33,23 @@ body {
display: inline;
border-left: 1px solid #d3d3d3;
border-right: 1px solid #fff;
height: 32px;
height: 16px;
width:0px;
margin: 4px;
}
#controls > a > img {
margin: 2px;
margin: 4px;
height: 16px;
}
#controls > button {
line-height: 32px;
line-height: 16px;
}
#controls > button > img {
width: 32px;
height: 32px;
width: 16px;
height: 16px;
}
#controls > button[disabled] > img {
@ -60,7 +61,7 @@ body {
}
#fileInput {
line-height: 32px;
line-height: 16px;
}
span#info {

View File

@ -3,10 +3,10 @@
<head>
<title>Simple pdf.js page viewer</title>
<link rel="stylesheet" href="viewer.css"/>
<script type="text/javascript" src="compatibility.js"></script>
<!-- PDFJSSCRIPT_INCLUDE_BUILD -->
<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/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/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>
</head>
<body>
<div id="controls">
<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
</button>
<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
</button>
@ -51,10 +53,10 @@
<div class="separator"></div>
<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 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>
<div class="separator"></div>
@ -74,12 +76,12 @@
<div class="separator"></div>
<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
</button>
<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
</button>
@ -89,8 +91,8 @@
<div class="separator"></div>
<a href="#" id="viewBookmark" title="Current View (bookmark or copy the location)">
<img src="images/bookmark.svg" alt="Bookmark" align="top" height="32"/>
<a href="#" id="viewBookmark" title="Bookmark (or copy) current location">
<img src="images/bookmark.svg" alt="Bookmark" align="top" height="16"/>
</a>
<span id="info">--</span>
@ -106,15 +108,15 @@
</div>
<div id="sidebarControls">
<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 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>
</div>
</div>
</div>
<div id="loading">Loading... 0%</div>
<div id="viewer"></div>
</body>

View File

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