@@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
22
22
(typeof window !== 'undefined' ? window : this ).PDFJS = {};
23
23
}
24
24
25
- PDFJS .version = '1.1.337 ' ;
26
- PDFJS .build = '61f9052 ' ;
25
+ PDFJS .version = '1.1.399 ' ;
26
+ PDFJS .build = '23cb01c ' ;
27
27
28
28
(function pdfjsWrapper () {
29
29
// Use strict in our context only - users might not want it
@@ -1508,6 +1508,10 @@ function MessageHandler(name, comObj) {
1508
1508
data : result
1509
1509
});
1510
1510
}, function (reason ) {
1511
+ if (reason instanceof Error ) {
1512
+ // Serialize error to avoid "DataCloneError"
1513
+ reason = reason + '';
1514
+ }
1511
1515
comObj .postMessage ({
1512
1516
isReply : true ,
1513
1517
callbackId : data .callbackId ,
@@ -1751,6 +1755,14 @@ PDFJS.openExternalLinksInNewWindow = (
1751
1755
PDFJS .openExternalLinksInNewWindow === undefined ?
1752
1756
false : PDFJS .openExternalLinksInNewWindow );
1753
1757
1758
+ /**
1759
+ * Determines if we can eval strings as JS. Primarily used to improve
1760
+ * performance for font rendering.
1761
+ * @var {boolean}
1762
+ */
1763
+ PDFJS .isEvalSupported = (PDFJS .isEvalSupported === undefined ?
1764
+ true : PDFJS .isEvalSupported );
1765
+
1754
1766
/**
1755
1767
* Document initialization / loading parameters object.
1756
1768
*
@@ -1861,6 +1873,8 @@ PDFJS.getDocument = function getDocument(src,
1861
1873
} else if (typeof pdfBytes === 'object' && pdfBytes !== null &&
1862
1874
!isNaN (pdfBytes .length )) {
1863
1875
params [key ] = new Uint8Array (pdfBytes );
1876
+ } else if (isArrayBuffer (pdfBytes )) {
1877
+ params [key ] = new Uint8Array (pdfBytes );
1864
1878
} else {
1865
1879
error ('Invalid PDF binary data: either typed array, string or ' +
1866
1880
'array-like object is expected in the data property.' );
@@ -5773,7 +5787,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
5773
5787
for (var j = 0 , jj = ps .length ; j < jj ; j ++) {
5774
5788
coords [pIndex ] = coordsMap [ps [j ]];
5775
5789
coords [pIndex + 1 ] = coordsMap [ps [j ] + 1 ];
5776
- colors [cIndex ] = colorsMap [cs [i ]];
5790
+ colors [cIndex ] = colorsMap [cs [j ]];
5777
5791
colors [cIndex + 1 ] = colorsMap [cs [j ] + 1 ];
5778
5792
colors [cIndex + 2 ] = colorsMap [cs [j ] + 2 ];
5779
5793
pIndex += 2 ;
@@ -6311,6 +6325,18 @@ var FontLoader = {
6311
6325
));
6312
6326
},
6313
6327
6328
+ get isEvalSupported () {
6329
+ var evalSupport = false ;
6330
+ if (PDFJS .isEvalSupported ) {
6331
+ try {
6332
+ /* jshint evil: true */
6333
+ new Function ('');
6334
+ evalSupport = true ;
6335
+ } catch (e ) {}
6336
+ }
6337
+ return shadow (this , 'isEvalSupported' , evalSupport );
6338
+ },
6339
+
6314
6340
loadTestFontId : 0 ,
6315
6341
6316
6342
loadingContext : {
@@ -6587,9 +6613,40 @@ var FontFaceObject = (function FontFaceObjectClosure() {
6587
6613
6588
6614
getPathGenerator : function FontLoader_getPathGenerator (objs , character ) {
6589
6615
if (!(character in this .compiledGlyphs )) {
6590
- var js = objs .get (this .loadedName + '_path_' + character );
6591
- /*jshint -W054 */
6592
- this .compiledGlyphs [character ] = new Function ('c' , 'size' , js );
6616
+ var cmds = objs .get (this .loadedName + '_path_' + character );
6617
+ var current , i , len ;
6618
+
6619
+ // If we can, compile cmds into JS for MAXIMUM SPEED
6620
+ if (FontLoader .isEvalSupported ) {
6621
+ var args , js = '';
6622
+ for (i = 0 , len = cmds .length ; i < len ; i ++) {
6623
+ current = cmds [i ];
6624
+
6625
+ if (current .args !== undefined ) {
6626
+ args = current .args .join (',' );
6627
+ } else {
6628
+ args = '';
6629
+ }
6630
+
6631
+ js += 'c.' + current .cmd + '(' + args + ');\n' ;
6632
+ }
6633
+ /* jshint -W054 */
6634
+ this .compiledGlyphs [character ] = new Function ('c' , 'size' , js );
6635
+ } else {
6636
+ // But fall back on using Function.prototype.apply() if we're
6637
+ // blocked from using eval() for whatever reason (like CSP policies)
6638
+ this .compiledGlyphs [character ] = function (c , size ) {
6639
+ for (i = 0 , len = cmds .length ; i < len ; i ++) {
6640
+ current = cmds [i ];
6641
+
6642
+ if (current .cmd === 'scale' ) {
6643
+ current .args = [size , -size ];
6644
+ }
6645
+
6646
+ c [current .cmd ].apply (c , current .args );
6647
+ }
6648
+ };
6649
+ }
6593
6650
}
6594
6651
return this .compiledGlyphs [character ];
6595
6652
}
0 commit comments