pdfjs-dist 2.5.207 → 2.6.347
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/bower.json +1 -1
- package/build/pdf.js +867 -216
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +10214 -8547
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/es5/build/pdf.js +2023 -1046
- package/es5/build/pdf.js.map +1 -1
- package/es5/build/pdf.min.js +22 -0
- package/es5/build/pdf.worker.js +11136 -8144
- package/es5/build/pdf.worker.js.map +1 -1
- package/es5/build/pdf.worker.min.js +22 -0
- package/es5/image_decoders/pdf.image_decoders.js +12529 -0
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
- package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/pdf_viewer.css +8 -5
- package/es5/web/pdf_viewer.js +195 -51
- package/es5/web/pdf_viewer.js.map +1 -1
- package/image_decoders/pdf.image_decoders.js +24 -16
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/core/annotation.js +479 -43
- package/lib/core/cff_parser.js +643 -615
- package/lib/core/chunked_stream.js +64 -50
- package/lib/core/colorspace.js +126 -104
- package/lib/core/crypto.js +37 -0
- package/lib/core/document.js +128 -75
- package/lib/core/evaluator.js +3015 -2754
- package/lib/core/fonts.js +47 -46
- package/lib/core/function.js +79 -6
- package/lib/core/image.js +364 -357
- package/lib/core/image_utils.js +109 -8
- package/lib/core/jpg.js +8 -3
- package/lib/core/obj.js +255 -34
- package/lib/core/operator_list.js +17 -15
- package/lib/core/parser.js +40 -3
- package/lib/core/pattern.js +24 -11
- package/lib/core/primitives.js +112 -53
- package/lib/core/type1_parser.js +2 -0
- package/lib/core/worker.js +102 -37
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +51 -10
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +140 -54
- package/lib/display/canvas.js +215 -46
- package/lib/display/display_utils.js +55 -18
- package/lib/display/fetch_stream.js +6 -0
- package/lib/display/font_loader.js +26 -15
- package/lib/display/metadata.js +1 -7
- package/lib/display/network.js +0 -14
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/svg.js +1 -1
- package/lib/display/text_layer.js +4 -1
- package/lib/pdf.js +2 -2
- package/lib/pdf.worker.js +2 -2
- package/lib/shared/is_node.js +1 -1
- package/lib/shared/util.js +13 -10
- package/lib/test/unit/annotation_spec.js +520 -50
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +16 -6
- package/lib/test/unit/cmap_spec.js +4 -4
- package/lib/test/unit/colorspace_spec.js +216 -24
- package/lib/test/unit/crypto_spec.js +51 -4
- package/lib/test/unit/custom_spec.js +129 -1
- package/lib/test/unit/document_spec.js +112 -1
- package/lib/test/unit/evaluator_spec.js +29 -10
- package/lib/test/unit/jasmine-boot.js +1 -1
- package/lib/test/unit/metadata_spec.js +3 -3
- package/lib/test/unit/primitives_spec.js +242 -63
- package/lib/test/unit/test_utils.js +42 -89
- package/lib/test/unit/testreporter.js +17 -6
- package/lib/test/unit/util_spec.js +13 -12
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +13 -9
- package/lib/web/app.js +231 -26
- package/lib/web/app_options.js +1 -6
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +53 -4
- package/lib/web/download_manager.js +3 -10
- package/lib/web/firefox_print_service.js +32 -12
- package/lib/web/firefoxcom.js +20 -6
- package/lib/web/interfaces.js +1 -1
- package/lib/web/pdf_attachment_viewer.js +80 -38
- package/lib/web/pdf_find_controller.js +2 -1
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_outline_viewer.js +24 -57
- package/lib/web/pdf_page_view.js +29 -6
- package/lib/web/pdf_print_service.js +13 -11
- package/lib/web/pdf_sidebar.js +46 -25
- package/lib/web/pdf_thumbnail_view.js +16 -3
- package/lib/web/pdf_thumbnail_viewer.js +17 -1
- package/lib/web/pdf_viewer.component.js +2 -2
- package/lib/web/preferences.js +1 -1
- package/lib/web/toolbar.js +1 -1
- package/lib/web/ui_utils.js +7 -1
- package/package.json +3 -1
- package/types/display/annotation_layer.d.ts +61 -0
- package/types/display/annotation_storage.d.ts +36 -0
- package/types/display/api.d.ts +1107 -0
- package/types/display/api_compatibility.d.ts +1 -0
- package/types/display/canvas.d.ts +4 -0
- package/types/display/content_disposition.d.ts +7 -0
- package/types/display/display_utils.d.ts +243 -0
- package/types/display/fetch_stream.d.ts +67 -0
- package/types/display/font_loader.d.ts +19 -0
- package/types/display/metadata.d.ts +9 -0
- package/types/display/network.d.ts +80 -0
- package/types/display/network_utils.d.ts +14 -0
- package/types/display/node_stream.d.ts +72 -0
- package/types/display/node_utils.d.ts +6 -0
- package/types/display/optional_content_config.d.ts +12 -0
- package/types/display/pattern_helper.d.ts +5 -0
- package/types/display/svg.d.ts +2 -0
- package/types/display/text_layer.d.ts +83 -0
- package/types/display/transport_stream.d.ts +57 -0
- package/types/display/webgl.d.ts +20 -0
- package/types/display/worker_options.d.ts +27 -0
- package/types/display/xml_parser.d.ts +35 -0
- package/types/pdf.d.ts +33 -0
- package/types/shared/compatibility.d.ts +1 -0
- package/types/shared/is_node.d.ts +1 -0
- package/types/shared/message_handler.d.ts +62 -0
- package/types/shared/util.d.ts +421 -0
- package/web/images/shadow.png +0 -0
- package/web/pdf_viewer.css +8 -5
- package/web/pdf_viewer.js +109 -33
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +1 -9
- package/es5/web/images/texture.png +0 -0
- package/web/images/texture.png +0 -0
package/lib/core/fonts.js
CHANGED
@@ -522,13 +522,6 @@ var Font = function FontClosure() {
|
|
522
522
|
this.seacMap = properties.seacMap;
|
523
523
|
}
|
524
524
|
|
525
|
-
Font.getFontID = function () {
|
526
|
-
var ID = 1;
|
527
|
-
return function Font_getFontID() {
|
528
|
-
return String(ID++);
|
529
|
-
};
|
530
|
-
}();
|
531
|
-
|
532
525
|
function int16(b0, b1) {
|
533
526
|
return (b0 << 8) + b1;
|
534
527
|
}
|
@@ -1279,7 +1272,7 @@ var Font = function FontClosure() {
|
|
1279
1272
|
continue;
|
1280
1273
|
}
|
1281
1274
|
|
1282
|
-
if (platformId === 0 && encodingId === 0) {
|
1275
|
+
if (platformId === 0 && (encodingId === 0 || encodingId === 1 || encodingId === 3)) {
|
1283
1276
|
useTable = true;
|
1284
1277
|
} else if (platformId === 1 && encodingId === 0) {
|
1285
1278
|
useTable = true;
|
@@ -1669,28 +1662,40 @@ var Font = function FontClosure() {
|
|
1669
1662
|
var oldGlyfData = glyf.data;
|
1670
1663
|
var oldGlyfDataLength = oldGlyfData.length;
|
1671
1664
|
var newGlyfData = new Uint8Array(oldGlyfDataLength);
|
1672
|
-
var startOffset = itemDecode(locaData, 0);
|
1673
|
-
var writeOffset = 0;
|
1674
|
-
var missingGlyphs = Object.create(null);
|
1675
|
-
itemEncode(locaData, 0, writeOffset);
|
1676
1665
|
var i, j;
|
1666
|
+
const locaEntries = [];
|
1677
1667
|
|
1678
|
-
for (i = 0, j =
|
1679
|
-
|
1668
|
+
for (i = 0, j = 0; i < numGlyphs + 1; i++, j += itemSize) {
|
1669
|
+
let offset = itemDecode(locaData, j);
|
1680
1670
|
|
1681
|
-
if (
|
1682
|
-
|
1671
|
+
if (offset > oldGlyfDataLength) {
|
1672
|
+
offset = oldGlyfDataLength;
|
1683
1673
|
}
|
1684
1674
|
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1675
|
+
locaEntries.push({
|
1676
|
+
index: i,
|
1677
|
+
offset,
|
1678
|
+
endOffset: 0
|
1679
|
+
});
|
1680
|
+
}
|
1688
1681
|
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1682
|
+
locaEntries.sort((a, b) => {
|
1683
|
+
return a.offset - b.offset;
|
1684
|
+
});
|
1685
|
+
|
1686
|
+
for (i = 0; i < numGlyphs; i++) {
|
1687
|
+
locaEntries[i].endOffset = locaEntries[i + 1].offset;
|
1688
|
+
}
|
1692
1689
|
|
1693
|
-
|
1690
|
+
locaEntries.sort((a, b) => {
|
1691
|
+
return a.index - b.index;
|
1692
|
+
});
|
1693
|
+
var missingGlyphs = Object.create(null);
|
1694
|
+
var writeOffset = 0;
|
1695
|
+
itemEncode(locaData, 0, writeOffset);
|
1696
|
+
|
1697
|
+
for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
|
1698
|
+
var glyphProfile = sanitizeGlyph(oldGlyfData, locaEntries[i].offset, locaEntries[i].endOffset, newGlyfData, writeOffset, hintsValid);
|
1694
1699
|
var newLength = glyphProfile.length;
|
1695
1700
|
|
1696
1701
|
if (newLength === 0) {
|
@@ -1703,7 +1708,6 @@ var Font = function FontClosure() {
|
|
1703
1708
|
|
1704
1709
|
writeOffset += newLength;
|
1705
1710
|
itemEncode(locaData, j, writeOffset);
|
1706
|
-
startOffset = endOffset;
|
1707
1711
|
}
|
1708
1712
|
|
1709
1713
|
if (writeOffset === 0) {
|
@@ -2348,14 +2352,13 @@ var Font = function FontClosure() {
|
|
2348
2352
|
var cmapEncodingId = cmapTable.encodingId;
|
2349
2353
|
var cmapMappings = cmapTable.mappings;
|
2350
2354
|
var cmapMappingsLength = cmapMappings.length;
|
2355
|
+
let baseEncoding = [];
|
2351
2356
|
|
2352
|
-
if (properties.hasEncoding && (
|
2353
|
-
|
2354
|
-
|
2355
|
-
if (properties.baseEncodingName === "MacRomanEncoding" || properties.baseEncodingName === "WinAnsiEncoding") {
|
2356
|
-
baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
|
2357
|
-
}
|
2357
|
+
if (properties.hasEncoding && (properties.baseEncodingName === "MacRomanEncoding" || properties.baseEncodingName === "WinAnsiEncoding")) {
|
2358
|
+
baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
|
2359
|
+
}
|
2358
2360
|
|
2361
|
+
if (properties.hasEncoding && !this.isSymbolicFont && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0)) {
|
2359
2362
|
var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
|
2360
2363
|
|
2361
2364
|
for (let charCode = 0; charCode < 256; charCode++) {
|
@@ -2382,31 +2385,16 @@ var Font = function FontClosure() {
|
|
2382
2385
|
unicodeOrCharCode = _encodings.MacRomanEncoding.indexOf(standardGlyphName);
|
2383
2386
|
}
|
2384
2387
|
|
2385
|
-
var found = false;
|
2386
|
-
|
2387
2388
|
for (let i = 0; i < cmapMappingsLength; ++i) {
|
2388
2389
|
if (cmapMappings[i].charCode !== unicodeOrCharCode) {
|
2389
2390
|
continue;
|
2390
2391
|
}
|
2391
2392
|
|
2392
2393
|
charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
|
2393
|
-
found = true;
|
2394
2394
|
break;
|
2395
2395
|
}
|
2396
|
-
|
2397
|
-
if (!found && properties.glyphNames) {
|
2398
|
-
var glyphId = properties.glyphNames.indexOf(glyphName);
|
2399
|
-
|
2400
|
-
if (glyphId === -1 && standardGlyphName !== glyphName) {
|
2401
|
-
glyphId = properties.glyphNames.indexOf(standardGlyphName);
|
2402
|
-
}
|
2403
|
-
|
2404
|
-
if (glyphId > 0 && hasGlyph(glyphId)) {
|
2405
|
-
charCodeToGlyphId[charCode] = glyphId;
|
2406
|
-
}
|
2407
|
-
}
|
2408
2396
|
}
|
2409
|
-
} else if (cmapPlatformId === 0
|
2397
|
+
} else if (cmapPlatformId === 0) {
|
2410
2398
|
for (let i = 0; i < cmapMappingsLength; ++i) {
|
2411
2399
|
charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
|
2412
2400
|
}
|
@@ -2421,6 +2409,19 @@ var Font = function FontClosure() {
|
|
2421
2409
|
charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
|
2422
2410
|
}
|
2423
2411
|
}
|
2412
|
+
|
2413
|
+
if (properties.glyphNames && baseEncoding.length) {
|
2414
|
+
for (let i = 0; i < 256; ++i) {
|
2415
|
+
if (charCodeToGlyphId[i] === undefined && baseEncoding[i]) {
|
2416
|
+
glyphName = baseEncoding[i];
|
2417
|
+
const glyphId = properties.glyphNames.indexOf(glyphName);
|
2418
|
+
|
2419
|
+
if (glyphId > 0 && hasGlyph(glyphId)) {
|
2420
|
+
charCodeToGlyphId[i] = glyphId;
|
2421
|
+
}
|
2422
|
+
}
|
2423
|
+
}
|
2424
|
+
}
|
2424
2425
|
}
|
2425
2426
|
|
2426
2427
|
if (charCodeToGlyphId.length === 0) {
|
package/lib/core/function.js
CHANGED
@@ -27,12 +27,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
27
27
|
exports.isPDFFunction = isPDFFunction;
|
28
28
|
exports.PostScriptCompiler = exports.PostScriptEvaluator = exports.PDFFunctionFactory = void 0;
|
29
29
|
|
30
|
-
var _util = require("../shared/util.js");
|
31
|
-
|
32
30
|
var _primitives = require("./primitives.js");
|
33
31
|
|
32
|
+
var _util = require("../shared/util.js");
|
33
|
+
|
34
34
|
var _ps_parser = require("./ps_parser.js");
|
35
35
|
|
36
|
+
var _image_utils = require("./image_utils.js");
|
37
|
+
|
36
38
|
class PDFFunctionFactory {
|
37
39
|
constructor({
|
38
40
|
xref,
|
@@ -40,22 +42,93 @@ class PDFFunctionFactory {
|
|
40
42
|
}) {
|
41
43
|
this.xref = xref;
|
42
44
|
this.isEvalSupported = isEvalSupported !== false;
|
45
|
+
this._localFunctionCache = null;
|
43
46
|
}
|
44
47
|
|
45
48
|
create(fn) {
|
46
|
-
|
49
|
+
const cachedFunction = this.getCached(fn);
|
50
|
+
|
51
|
+
if (cachedFunction) {
|
52
|
+
return cachedFunction;
|
53
|
+
}
|
54
|
+
|
55
|
+
const parsedFunction = PDFFunction.parse({
|
47
56
|
xref: this.xref,
|
48
57
|
isEvalSupported: this.isEvalSupported,
|
49
|
-
fn
|
58
|
+
fn: fn instanceof _primitives.Ref ? this.xref.fetch(fn) : fn
|
50
59
|
});
|
60
|
+
|
61
|
+
this._cache(fn, parsedFunction);
|
62
|
+
|
63
|
+
return parsedFunction;
|
51
64
|
}
|
52
65
|
|
53
66
|
createFromArray(fnObj) {
|
54
|
-
|
67
|
+
const cachedFunction = this.getCached(fnObj);
|
68
|
+
|
69
|
+
if (cachedFunction) {
|
70
|
+
return cachedFunction;
|
71
|
+
}
|
72
|
+
|
73
|
+
const parsedFunction = PDFFunction.parseArray({
|
55
74
|
xref: this.xref,
|
56
75
|
isEvalSupported: this.isEvalSupported,
|
57
|
-
fnObj
|
76
|
+
fnObj: fnObj instanceof _primitives.Ref ? this.xref.fetch(fnObj) : fnObj
|
58
77
|
});
|
78
|
+
|
79
|
+
this._cache(fnObj, parsedFunction);
|
80
|
+
|
81
|
+
return parsedFunction;
|
82
|
+
}
|
83
|
+
|
84
|
+
getCached(cacheKey) {
|
85
|
+
let fnRef;
|
86
|
+
|
87
|
+
if (cacheKey instanceof _primitives.Ref) {
|
88
|
+
fnRef = cacheKey;
|
89
|
+
} else if (cacheKey instanceof _primitives.Dict) {
|
90
|
+
fnRef = cacheKey.objId;
|
91
|
+
} else if ((0, _primitives.isStream)(cacheKey)) {
|
92
|
+
fnRef = cacheKey.dict && cacheKey.dict.objId;
|
93
|
+
}
|
94
|
+
|
95
|
+
if (fnRef) {
|
96
|
+
if (!this._localFunctionCache) {
|
97
|
+
this._localFunctionCache = new _image_utils.LocalFunctionCache();
|
98
|
+
}
|
99
|
+
|
100
|
+
const localFunction = this._localFunctionCache.getByRef(fnRef);
|
101
|
+
|
102
|
+
if (localFunction) {
|
103
|
+
return localFunction;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
return null;
|
108
|
+
}
|
109
|
+
|
110
|
+
_cache(cacheKey, parsedFunction) {
|
111
|
+
if (!parsedFunction) {
|
112
|
+
throw new Error('PDFFunctionFactory._cache - expected "parsedFunction" argument.');
|
113
|
+
}
|
114
|
+
|
115
|
+
let fnRef;
|
116
|
+
|
117
|
+
if (cacheKey instanceof _primitives.Ref) {
|
118
|
+
fnRef = cacheKey;
|
119
|
+
} else if (cacheKey instanceof _primitives.Dict) {
|
120
|
+
fnRef = cacheKey.objId;
|
121
|
+
} else if ((0, _primitives.isStream)(cacheKey)) {
|
122
|
+
fnRef = cacheKey.dict && cacheKey.dict.objId;
|
123
|
+
}
|
124
|
+
|
125
|
+
if (fnRef) {
|
126
|
+
if (!this._localFunctionCache) {
|
127
|
+
this._localFunctionCache = new _image_utils.LocalFunctionCache();
|
128
|
+
}
|
129
|
+
|
130
|
+
this._localFunctionCache.set(null, fnRef, parsedFunction);
|
131
|
+
}
|
59
132
|
}
|
60
133
|
|
61
134
|
}
|