Skip to content

Commit 9867c19

Browse files
committed
upgrade pdf.js. sayanee#62
1 parent 37da079 commit 9867c19

File tree

3 files changed

+245
-146
lines changed

3 files changed

+245
-146
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"homepage": "http://github.com/sayanee/angularjs-pdf",
88
"dependencies": {
99
"angular": "1.4.7",
10-
"pdfjs-dist": "1.2.43"
10+
"pdfjs-dist": "1.2.83"
1111
},
1212
"ignore": [
1313
"**/.*",

example/js/lib/pdf.js

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
2222
(typeof window !== 'undefined' ? window : this).PDFJS = {};
2323
}
2424

25-
PDFJS.version = '1.2.43';
26-
PDFJS.build = '1672c77';
25+
PDFJS.version = '1.2.83';
26+
PDFJS.build = '1280b7b';
2727

2828
(function pdfjsWrapper() {
2929
// Use strict in our context only - users might not want it
@@ -1699,7 +1699,9 @@ PDFJS.disableWorker = (PDFJS.disableWorker === undefined ?
16991699
/**
17001700
* Path and filename of the worker file. Required when the worker is enabled in
17011701
* development mode. If unspecified in the production build, the worker will be
1702-
* loaded based on the location of the pdf.js file.
1702+
* loaded based on the location of the pdf.js file. It is recommended that
1703+
* the workerSrc is set in a custom application to prevent issues caused by
1704+
* third-party frameworks and libraries.
17031705
* @var {string}
17041706
*/
17051707
PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc);
@@ -4875,16 +4877,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
48754877
var x = 0, i;
48764878
for (i = 0; i < glyphsLength; ++i) {
48774879
var glyph = glyphs[i];
4878-
if (glyph === null) {
4879-
// word break
4880-
x += fontDirection * wordSpacing;
4881-
continue;
4882-
} else if (isNum(glyph)) {
4880+
if (isNum(glyph)) {
48834881
x += spacingDir * glyph * fontSize / 1000;
48844882
continue;
48854883
}
48864884

48874885
var restoreNeeded = false;
4886+
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
48884887
var character = glyph.fontChar;
48894888
var accent = glyph.accent;
48904889
var scaledX, scaledY, scaledAccentX, scaledAccentY;
@@ -4928,7 +4927,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
49284927
}
49294928
}
49304929

4931-
var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
4930+
var charWidth = width * widthAdvanceScale + spacing * fontDirection;
49324931
x += charWidth;
49334932

49344933
if (restoreNeeded) {
@@ -4973,18 +4972,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
49734972

49744973
for (i = 0; i < glyphsLength; ++i) {
49754974
glyph = glyphs[i];
4976-
if (glyph === null) {
4977-
// word break
4978-
this.ctx.translate(wordSpacing, 0);
4979-
current.x += wordSpacing * textHScale;
4980-
continue;
4981-
} else if (isNum(glyph)) {
4975+
if (isNum(glyph)) {
49824976
spacingLength = spacingDir * glyph * fontSize / 1000;
49834977
this.ctx.translate(spacingLength, 0);
49844978
current.x += spacingLength * textHScale;
49854979
continue;
49864980
}
49874981

4982+
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
49884983
var operatorList = font.charProcOperatorList[glyph.operatorListId];
49894984
if (!operatorList) {
49904985
warn('Type3 character \"' + glyph.operatorListId +
@@ -4999,7 +4994,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
49994994
this.restore();
50004995

50014996
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
5002-
width = transformed[0] * fontSize + charSpacing;
4997+
width = transformed[0] * fontSize + spacing;
50034998

50044999
ctx.translate(width, 0);
50055000
current.x += width * textHScale;
@@ -8291,10 +8286,8 @@ if (!PDFJS.workerSrc && typeof document !== 'undefined') {
82918286
// workerSrc is not set -- using last script url to define default location
82928287
PDFJS.workerSrc = (function () {
82938288
'use strict';
8294-
var scriptTagContainer = document.body ||
8295-
document.getElementsByTagName('head')[0];
8296-
var pdfjsSrc = scriptTagContainer.lastChild.src;
8297-
return pdfjsSrc && pdfjsSrc.replace(/\.js$/i, '.worker.js');
8289+
var pdfJsSrc = document.currentScript.src;
8290+
return pdfJsSrc && pdfJsSrc.replace(/\.js$/i, '.worker.js');
82988291
})();
82998292
}
83008293

0 commit comments

Comments
 (0)