Skip to content

Commit

Permalink
⬆️ upgrade bower pdfjs
Browse files Browse the repository at this point in the history
  • Loading branch information
sayanee committed Aug 30, 2015
1 parent bfcbedf commit d4da549
Show file tree
Hide file tree
Showing 3 changed files with 253 additions and 211 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"homepage": "https://github.com/sayanee/angularjs-pdf",
"dependencies": {
"angular": "1.3.15",
"pdfjs-dist": "1.1.337"
"pdfjs-dist": "1.1.399"
},
"ignore": [
"**/.*",
Expand Down
69 changes: 63 additions & 6 deletions example/js/lib/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}

PDFJS.version = '1.1.337';
PDFJS.build = '61f9052';
PDFJS.version = '1.1.399';
PDFJS.build = '23cb01c';

(function pdfjsWrapper() {
// Use strict in our context only - users might not want it
Expand Down Expand Up @@ -1508,6 +1508,10 @@ function MessageHandler(name, comObj) {
data: result
});
}, function (reason) {
if (reason instanceof Error) {
// Serialize error to avoid "DataCloneError"
reason = reason + '';
}
comObj.postMessage({
isReply: true,
callbackId: data.callbackId,
Expand Down Expand Up @@ -1751,6 +1755,14 @@ PDFJS.openExternalLinksInNewWindow = (
PDFJS.openExternalLinksInNewWindow === undefined ?
false : PDFJS.openExternalLinksInNewWindow);

/**
* Determines if we can eval strings as JS. Primarily used to improve
* performance for font rendering.
* @var {boolean}
*/
PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
true : PDFJS.isEvalSupported);

/**
* Document initialization / loading parameters object.
*
Expand Down Expand Up @@ -1861,6 +1873,8 @@ PDFJS.getDocument = function getDocument(src,
} else if (typeof pdfBytes === 'object' && pdfBytes !== null &&
!isNaN(pdfBytes.length)) {
params[key] = new Uint8Array(pdfBytes);
} else if (isArrayBuffer(pdfBytes)) {
params[key] = new Uint8Array(pdfBytes);
} else {
error('Invalid PDF binary data: either typed array, string or ' +
'array-like object is expected in the data property.');
Expand Down Expand Up @@ -5773,7 +5787,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
for (var j = 0, jj = ps.length; j < jj; j++) {
coords[pIndex] = coordsMap[ps[j]];
coords[pIndex + 1] = coordsMap[ps[j] + 1];
colors[cIndex] = colorsMap[cs[i]];
colors[cIndex] = colorsMap[cs[j]];
colors[cIndex + 1] = colorsMap[cs[j] + 1];
colors[cIndex + 2] = colorsMap[cs[j] + 2];
pIndex += 2;
Expand Down Expand Up @@ -6311,6 +6325,18 @@ var FontLoader = {
));
},

get isEvalSupported() {
var evalSupport = false;
if (PDFJS.isEvalSupported) {
try {
/* jshint evil: true */
new Function('');
evalSupport = true;
} catch (e) {}
}
return shadow(this, 'isEvalSupported', evalSupport);
},

loadTestFontId: 0,

loadingContext: {
Expand Down Expand Up @@ -6587,9 +6613,40 @@ var FontFaceObject = (function FontFaceObjectClosure() {

getPathGenerator: function FontLoader_getPathGenerator(objs, character) {
if (!(character in this.compiledGlyphs)) {
var js = objs.get(this.loadedName + '_path_' + character);
/*jshint -W054 */
this.compiledGlyphs[character] = new Function('c', 'size', js);
var cmds = objs.get(this.loadedName + '_path_' + character);
var current, i, len;

// If we can, compile cmds into JS for MAXIMUM SPEED
if (FontLoader.isEvalSupported) {
var args, js = '';
for (i = 0, len = cmds.length; i < len; i++) {
current = cmds[i];

if (current.args !== undefined) {
args = current.args.join(',');
} else {
args = '';
}

js += 'c.' + current.cmd + '(' + args + ');\n';
}
/* jshint -W054 */
this.compiledGlyphs[character] = new Function('c', 'size', js);
} else {
// But fall back on using Function.prototype.apply() if we're
// blocked from using eval() for whatever reason (like CSP policies)
this.compiledGlyphs[character] = function(c, size) {
for (i = 0, len = cmds.length; i < len; i++) {
current = cmds[i];

if (current.cmd === 'scale') {
current.args = [size, -size];
}

c[current.cmd].apply(c, current.args);
}
};
}
}
return this.compiledGlyphs[character];
}
Expand Down
Loading

0 comments on commit d4da549

Please sign in to comment.