pdfjs-dist 2.4.456 → 2.5.207
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 +4447 -4379
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +8549 -8507
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/es5/build/pdf.js +14755 -14540
- package/es5/build/pdf.js.map +1 -1
- package/es5/build/pdf.worker.js +9830 -9469
- package/es5/build/pdf.worker.js.map +1 -1
- package/es5/web/pdf_viewer.css +5 -9
- package/es5/web/pdf_viewer.js +157 -172
- package/es5/web/pdf_viewer.js.map +1 -1
- package/image_decoders/pdf.image_decoders.js +107 -93
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/README.md +2 -2
- package/lib/core/ccitt.js +7 -7
- package/lib/core/cff_parser.js +1 -1
- package/lib/core/chunked_stream.js +5 -5
- package/lib/core/cmap.js +13 -0
- package/lib/core/document.js +22 -18
- package/lib/core/evaluator.js +285 -247
- package/lib/core/font_renderer.js +7 -7
- package/lib/core/fonts.js +163 -147
- package/lib/core/function.js +4 -5
- package/lib/core/glyphlist.js +4523 -4523
- package/lib/core/image.js +19 -44
- package/lib/core/image_utils.js +123 -47
- package/lib/core/jpeg_stream.js +2 -116
- package/lib/core/jpg.js +47 -55
- package/lib/core/jpx.js +6 -6
- package/lib/core/metrics.js +2916 -2916
- package/lib/core/obj.js +18 -7
- package/lib/core/operator_list.js +5 -0
- package/lib/core/parser.js +1 -1
- package/lib/core/pdf_manager.js +2 -2
- package/lib/core/primitives.js +4 -0
- package/lib/core/standard_fonts.js +103 -103
- package/lib/core/type1_parser.js +6 -6
- package/lib/core/worker.js +31 -24
- package/lib/core/worker_stream.js +1 -1
- package/lib/display/annotation_layer.js +3 -0
- package/lib/display/api.js +29 -137
- package/lib/display/api_compatibility.js +11 -18
- package/lib/display/canvas.js +7 -34
- package/lib/display/content_disposition.js +4 -4
- package/lib/display/display_utils.js +6 -15
- package/lib/display/fetch_stream.js +3 -1
- package/lib/display/font_loader.js +2 -2
- package/lib/display/network.js +1 -1
- package/lib/display/node_stream.js +10 -8
- package/lib/display/pattern_helper.js +1 -1
- package/lib/display/svg.js +61 -31
- package/lib/display/text_layer.js +44 -32
- package/lib/display/transport_stream.js +3 -3
- package/lib/pdf.js +210 -48
- package/lib/pdf.worker.js +12 -4
- package/lib/shared/compatibility.js +2 -0
- package/lib/shared/is_node.js +1 -1
- package/lib/shared/message_handler.js +6 -6
- package/lib/shared/util.js +15 -9
- package/lib/test/unit/api_spec.js +165 -95
- package/lib/test/unit/cff_parser_spec.js +12 -12
- package/lib/test/unit/clitests_helper.js +1 -1
- package/lib/test/unit/display_svg_spec.js +1 -5
- package/lib/test/unit/jasmine-boot.js +2 -2
- package/lib/test/unit/node_stream_spec.js +5 -3
- package/lib/test/unit/parser_spec.js +3 -3
- package/lib/test/unit/test_utils.js +1 -1
- package/lib/test/unit/testreporter.js +4 -4
- package/lib/test/unit/ui_utils_spec.js +1 -55
- package/lib/test/unit/unicode_spec.js +1 -1
- package/lib/web/app.js +247 -159
- package/lib/web/app_options.js +16 -10
- package/lib/web/base_viewer.js +14 -6
- package/lib/web/download_manager.js +3 -1
- package/lib/web/firefox_print_service.js +1 -1
- package/lib/web/firefoxcom.js +16 -4
- package/lib/web/pdf_attachment_viewer.js +14 -7
- package/lib/web/pdf_document_properties.js +11 -16
- package/lib/web/pdf_find_bar.js +3 -3
- package/lib/web/pdf_find_controller.js +3 -3
- package/lib/web/pdf_history.js +7 -5
- package/lib/web/pdf_link_service.js +7 -8
- package/lib/web/pdf_page_view.js +1 -1
- package/lib/web/pdf_presentation_mode.js +6 -2
- package/lib/web/pdf_print_service.js +1 -1
- package/lib/web/pdf_single_page_viewer.js +2 -2
- package/lib/web/pdf_viewer.component.js +2 -2
- package/lib/web/pdf_viewer.js +2 -2
- package/lib/web/preferences.js +4 -1
- package/lib/web/text_layer_builder.js +1 -3
- package/lib/web/ui_utils.js +3 -55
- package/lib/web/view_history.js +8 -9
- package/lib/web/viewer_compatibility.js +14 -1
- package/package.json +1 -1
- package/web/pdf_viewer.css +5 -9
- package/web/pdf_viewer.js +97 -127
- package/web/pdf_viewer.js.map +1 -1
@@ -37,7 +37,7 @@ class PDFWorkerStream {
|
|
37
37
|
}
|
38
38
|
|
39
39
|
getFullReader() {
|
40
|
-
(0, _util.assert)(!this._fullRequestReader);
|
40
|
+
(0, _util.assert)(!this._fullRequestReader, "PDFWorkerStream.getFullReader can only be called once.");
|
41
41
|
this._fullRequestReader = new PDFWorkerStreamReader(this._msgHandler);
|
42
42
|
return this._fullRequestReader;
|
43
43
|
}
|
@@ -347,6 +347,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
|
|
347
347
|
}
|
348
348
|
|
349
349
|
element.disabled = this.data.readOnly;
|
350
|
+
element.name = this.data.fieldName;
|
350
351
|
|
351
352
|
if (this.data.maxLen !== null) {
|
352
353
|
element.maxLength = this.data.maxLen;
|
@@ -416,6 +417,7 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
|
|
416
417
|
const element = document.createElement("input");
|
417
418
|
element.disabled = this.data.readOnly;
|
418
419
|
element.type = "checkbox";
|
420
|
+
element.name = this.data.fieldName;
|
419
421
|
|
420
422
|
if (this.data.fieldValue && this.data.fieldValue !== "Off") {
|
421
423
|
element.setAttribute("checked", true);
|
@@ -467,6 +469,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|
467
469
|
this.container.className = "choiceWidgetAnnotation";
|
468
470
|
const selectElement = document.createElement("select");
|
469
471
|
selectElement.disabled = this.data.readOnly;
|
472
|
+
selectElement.name = this.data.fieldName;
|
470
473
|
|
471
474
|
if (!this.data.combo) {
|
472
475
|
selectElement.size = this.data.options.length;
|
package/lib/display/api.js
CHANGED
@@ -122,12 +122,8 @@ function getDocument(src) {
|
|
122
122
|
params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
|
123
123
|
params.CMapReaderFactory = params.CMapReaderFactory || _display_utils.DOMCMapReaderFactory;
|
124
124
|
params.ignoreErrors = params.stopAtErrors !== true;
|
125
|
+
params.fontExtraProperties = params.fontExtraProperties === true;
|
125
126
|
params.pdfBug = params.pdfBug === true;
|
126
|
-
const NativeImageDecoderValues = Object.values(_util.NativeImageDecoding);
|
127
|
-
|
128
|
-
if (params.nativeImageDecoderSupport === undefined || !NativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
|
129
|
-
params.nativeImageDecoderSupport = _api_compatibility.apiCompatibilityParams.nativeImageDecoderSupport || _util.NativeImageDecoding.DECODE;
|
130
|
-
}
|
131
127
|
|
132
128
|
if (!Number.isInteger(params.maxImageSize)) {
|
133
129
|
params.maxImageSize = -1;
|
@@ -153,10 +149,6 @@ function getDocument(src) {
|
|
153
149
|
params.disableAutoFetch = false;
|
154
150
|
}
|
155
151
|
|
156
|
-
if (typeof params.disableCreateObjectURL !== "boolean") {
|
157
|
-
params.disableCreateObjectURL = _api_compatibility.apiCompatibilityParams.disableCreateObjectURL || false;
|
158
|
-
}
|
159
|
-
|
160
152
|
(0, _util.setVerbosityLevel)(params.verbosity);
|
161
153
|
|
162
154
|
if (!worker) {
|
@@ -174,11 +166,9 @@ function getDocument(src) {
|
|
174
166
|
throw new Error("Loading aborted");
|
175
167
|
}
|
176
168
|
|
177
|
-
|
178
|
-
if (task.destroyed) {
|
179
|
-
throw new Error("Loading aborted");
|
180
|
-
}
|
169
|
+
const workerIdPromise = _fetchDocument(worker, params, rangeTransport, docId);
|
181
170
|
|
171
|
+
const networkStreamPromise = new Promise(function (resolve) {
|
182
172
|
let networkStream;
|
183
173
|
|
184
174
|
if (rangeTransport) {
|
@@ -201,6 +191,13 @@ function getDocument(src) {
|
|
201
191
|
});
|
202
192
|
}
|
203
193
|
|
194
|
+
resolve(networkStream);
|
195
|
+
});
|
196
|
+
return Promise.all([workerIdPromise, networkStreamPromise]).then(function ([workerId, networkStream]) {
|
197
|
+
if (task.destroyed) {
|
198
|
+
throw new Error("Loading aborted");
|
199
|
+
}
|
200
|
+
|
204
201
|
const messageHandler = new _message_handler.MessageHandler(docId, workerId, worker.port);
|
205
202
|
messageHandler.postMessageTransfers = worker.postMessageTransfers;
|
206
203
|
const transport = new WorkerTransport(messageHandler, task, networkStream, params);
|
@@ -224,7 +221,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|
224
221
|
|
225
222
|
return worker.messageHandler.sendWithPromise("GetDocRequest", {
|
226
223
|
docId,
|
227
|
-
apiVersion: '2.
|
224
|
+
apiVersion: '2.5.207',
|
228
225
|
source: {
|
229
226
|
data: source.data,
|
230
227
|
url: source.url,
|
@@ -235,12 +232,11 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|
235
232
|
},
|
236
233
|
maxImageSize: source.maxImageSize,
|
237
234
|
disableFontFace: source.disableFontFace,
|
238
|
-
disableCreateObjectURL: source.disableCreateObjectURL,
|
239
235
|
postMessageTransfers: worker.postMessageTransfers,
|
240
236
|
docBaseUrl: source.docBaseUrl,
|
241
|
-
nativeImageDecoderSupport: source.nativeImageDecoderSupport,
|
242
237
|
ignoreErrors: source.ignoreErrors,
|
243
|
-
isEvalSupported: source.isEvalSupported
|
238
|
+
isEvalSupported: source.isEvalSupported,
|
239
|
+
fontExtraProperties: source.fontExtraProperties
|
244
240
|
}).then(function (workerId) {
|
245
241
|
if (worker.destroyed) {
|
246
242
|
throw new Error("Worker was destroyed");
|
@@ -283,10 +279,6 @@ const PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
|
|
283
279
|
});
|
284
280
|
}
|
285
281
|
|
286
|
-
then(onFulfilled, onRejected) {
|
287
|
-
throw new Error("Removed API method: " + "PDFDocumentLoadingTask.then, use the `promise` getter instead.");
|
288
|
-
}
|
289
|
-
|
290
282
|
}
|
291
283
|
|
292
284
|
return PDFDocumentLoadingTask;
|
@@ -515,10 +507,6 @@ class PDFPageProxy {
|
|
515
507
|
offsetY = 0,
|
516
508
|
dontFlip = false
|
517
509
|
} = {}) {
|
518
|
-
if (arguments.length > 1 || typeof arguments[0] === "number") {
|
519
|
-
throw new Error("PDFPageProxy.getViewport is called with obsolete arguments.");
|
520
|
-
}
|
521
|
-
|
522
510
|
return new _display_utils.PageViewport({
|
523
511
|
viewBox: this.view,
|
524
512
|
scale,
|
@@ -1428,7 +1416,7 @@ class WorkerTransport {
|
|
1428
1416
|
loadingTask
|
1429
1417
|
} = this;
|
1430
1418
|
messageHandler.on("GetReader", (data, sink) => {
|
1431
|
-
(0, _util.assert)(this._networkStream);
|
1419
|
+
(0, _util.assert)(this._networkStream, "GetReader - no `IPDFStream` instance available.");
|
1432
1420
|
this._fullReader = this._networkStream.getFullReader();
|
1433
1421
|
|
1434
1422
|
this._fullReader.onProgress = evt => {
|
@@ -1448,7 +1436,7 @@ class WorkerTransport {
|
|
1448
1436
|
return;
|
1449
1437
|
}
|
1450
1438
|
|
1451
|
-
(0, _util.assert)((0, _util.isArrayBuffer)(value));
|
1439
|
+
(0, _util.assert)((0, _util.isArrayBuffer)(value), "GetReader - expected an ArrayBuffer.");
|
1452
1440
|
sink.enqueue(new Uint8Array(value), 1, [value]);
|
1453
1441
|
}).catch(reason => {
|
1454
1442
|
sink.error(reason);
|
@@ -1487,7 +1475,7 @@ class WorkerTransport {
|
|
1487
1475
|
return headersCapability.promise;
|
1488
1476
|
});
|
1489
1477
|
messageHandler.on("GetRangeReader", (data, sink) => {
|
1490
|
-
(0, _util.assert)(this._networkStream);
|
1478
|
+
(0, _util.assert)(this._networkStream, "GetRangeReader - no `IPDFStream` instance available.");
|
1491
1479
|
|
1492
1480
|
const rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
|
1493
1481
|
|
@@ -1506,7 +1494,7 @@ class WorkerTransport {
|
|
1506
1494
|
return;
|
1507
1495
|
}
|
1508
1496
|
|
1509
|
-
(0, _util.assert)((0, _util.isArrayBuffer)(value));
|
1497
|
+
(0, _util.assert)((0, _util.isArrayBuffer)(value), "GetRangeReader - expected an ArrayBuffer.");
|
1510
1498
|
sink.enqueue(new Uint8Array(value), 1, [value]);
|
1511
1499
|
}).catch(reason => {
|
1512
1500
|
sink.error(reason);
|
@@ -1631,19 +1619,22 @@ class WorkerTransport {
|
|
1631
1619
|
onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
|
1632
1620
|
fontRegistry
|
1633
1621
|
});
|
1634
|
-
this.fontLoader.bind(font).
|
1635
|
-
|
1636
|
-
}, reason => {
|
1637
|
-
messageHandler.sendWithPromise("FontFallback", {
|
1622
|
+
this.fontLoader.bind(font).catch(reason => {
|
1623
|
+
return messageHandler.sendWithPromise("FontFallback", {
|
1638
1624
|
id
|
1639
|
-
}).finally(() => {
|
1640
|
-
this.commonObjs.resolve(id, font);
|
1641
1625
|
});
|
1626
|
+
}).finally(() => {
|
1627
|
+
if (!params.fontExtraProperties && font.data) {
|
1628
|
+
font.data = null;
|
1629
|
+
}
|
1630
|
+
|
1631
|
+
this.commonObjs.resolve(id, font);
|
1642
1632
|
});
|
1643
1633
|
break;
|
1644
1634
|
|
1645
1635
|
case "FontPath":
|
1646
1636
|
case "FontType3Res":
|
1637
|
+
case "Image":
|
1647
1638
|
this.commonObjs.resolve(id, exportedData);
|
1648
1639
|
break;
|
1649
1640
|
|
@@ -1664,24 +1655,6 @@ class WorkerTransport {
|
|
1664
1655
|
}
|
1665
1656
|
|
1666
1657
|
switch (type) {
|
1667
|
-
case "JpegStream":
|
1668
|
-
return new Promise((resolve, reject) => {
|
1669
|
-
const img = new Image();
|
1670
|
-
|
1671
|
-
img.onload = function () {
|
1672
|
-
resolve(img);
|
1673
|
-
};
|
1674
|
-
|
1675
|
-
img.onerror = function () {
|
1676
|
-
reject(new Error("Error during JPEG image loading"));
|
1677
|
-
(0, _display_utils.releaseImageResources)(img);
|
1678
|
-
};
|
1679
|
-
|
1680
|
-
img.src = imageData;
|
1681
|
-
}).then(img => {
|
1682
|
-
pageProxy.objs.resolve(id, img);
|
1683
|
-
});
|
1684
|
-
|
1685
1658
|
case "Image":
|
1686
1659
|
pageProxy.objs.resolve(id, imageData);
|
1687
1660
|
const MAX_IMAGE_SIZE_TO_STORE = 8000000;
|
@@ -1711,71 +1684,6 @@ class WorkerTransport {
|
|
1711
1684
|
}
|
1712
1685
|
});
|
1713
1686
|
messageHandler.on("UnsupportedFeature", this._onUnsupportedFeature.bind(this));
|
1714
|
-
messageHandler.on("JpegDecode", data => {
|
1715
|
-
if (this.destroyed) {
|
1716
|
-
return Promise.reject(new Error("Worker was destroyed"));
|
1717
|
-
}
|
1718
|
-
|
1719
|
-
if (typeof document === "undefined") {
|
1720
|
-
return Promise.reject(new Error('"document" is not defined.'));
|
1721
|
-
}
|
1722
|
-
|
1723
|
-
const [imageUrl, components] = data;
|
1724
|
-
|
1725
|
-
if (components !== 3 && components !== 1) {
|
1726
|
-
return Promise.reject(new Error("Only 3 components or 1 component can be returned"));
|
1727
|
-
}
|
1728
|
-
|
1729
|
-
return new Promise(function (resolve, reject) {
|
1730
|
-
const img = new Image();
|
1731
|
-
|
1732
|
-
img.onload = function () {
|
1733
|
-
const {
|
1734
|
-
width,
|
1735
|
-
height
|
1736
|
-
} = img;
|
1737
|
-
const size = width * height;
|
1738
|
-
const rgbaLength = size * 4;
|
1739
|
-
const buf = new Uint8ClampedArray(size * components);
|
1740
|
-
let tmpCanvas = document.createElement("canvas");
|
1741
|
-
tmpCanvas.width = width;
|
1742
|
-
tmpCanvas.height = height;
|
1743
|
-
let tmpCtx = tmpCanvas.getContext("2d");
|
1744
|
-
tmpCtx.drawImage(img, 0, 0);
|
1745
|
-
const data = tmpCtx.getImageData(0, 0, width, height).data;
|
1746
|
-
|
1747
|
-
if (components === 3) {
|
1748
|
-
for (let i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
|
1749
|
-
buf[j] = data[i];
|
1750
|
-
buf[j + 1] = data[i + 1];
|
1751
|
-
buf[j + 2] = data[i + 2];
|
1752
|
-
}
|
1753
|
-
} else if (components === 1) {
|
1754
|
-
for (let i = 0, j = 0; i < rgbaLength; i += 4, j++) {
|
1755
|
-
buf[j] = data[i];
|
1756
|
-
}
|
1757
|
-
}
|
1758
|
-
|
1759
|
-
resolve({
|
1760
|
-
data: buf,
|
1761
|
-
width,
|
1762
|
-
height
|
1763
|
-
});
|
1764
|
-
(0, _display_utils.releaseImageResources)(img);
|
1765
|
-
tmpCanvas.width = 0;
|
1766
|
-
tmpCanvas.height = 0;
|
1767
|
-
tmpCanvas = null;
|
1768
|
-
tmpCtx = null;
|
1769
|
-
};
|
1770
|
-
|
1771
|
-
img.onerror = function () {
|
1772
|
-
reject(new Error("JpegDecode failed to load image"));
|
1773
|
-
(0, _display_utils.releaseImageResources)(img);
|
1774
|
-
};
|
1775
|
-
|
1776
|
-
img.src = imageUrl;
|
1777
|
-
});
|
1778
|
-
});
|
1779
1687
|
messageHandler.on("FetchBuiltInCMap", (data, sink) => {
|
1780
1688
|
if (this.destroyed) {
|
1781
1689
|
sink.error(new Error("Worker was destroyed"));
|
@@ -1944,9 +1852,7 @@ class WorkerTransport {
|
|
1944
1852
|
const params = this._params;
|
1945
1853
|
return (0, _util.shadow)(this, "loadingParams", {
|
1946
1854
|
disableAutoFetch: params.disableAutoFetch,
|
1947
|
-
|
1948
|
-
disableFontFace: params.disableFontFace,
|
1949
|
-
nativeImageDecoderSupport: params.nativeImageDecoderSupport
|
1855
|
+
disableFontFace: params.disableFontFace
|
1950
1856
|
});
|
1951
1857
|
}
|
1952
1858
|
|
@@ -1999,16 +1905,6 @@ class PDFObjects {
|
|
1999
1905
|
}
|
2000
1906
|
|
2001
1907
|
clear() {
|
2002
|
-
for (const objId in this._objs) {
|
2003
|
-
const {
|
2004
|
-
data
|
2005
|
-
} = this._objs[objId];
|
2006
|
-
|
2007
|
-
if (typeof Image !== "undefined" && data instanceof Image) {
|
2008
|
-
(0, _display_utils.releaseImageResources)(data);
|
2009
|
-
}
|
2010
|
-
}
|
2011
|
-
|
2012
1908
|
this._objs = Object.create(null);
|
2013
1909
|
}
|
2014
1910
|
|
@@ -2028,10 +1924,6 @@ class RenderTask {
|
|
2028
1924
|
this._internalRenderTask.cancel();
|
2029
1925
|
}
|
2030
1926
|
|
2031
|
-
then(onFulfilled, onRejected) {
|
2032
|
-
throw new Error("Removed API method: " + "RenderTask.then, use the `promise` getter instead.");
|
2033
|
-
}
|
2034
|
-
|
2035
1927
|
}
|
2036
1928
|
|
2037
1929
|
const InternalRenderTask = function InternalRenderTaskClosure() {
|
@@ -2200,7 +2092,7 @@ const InternalRenderTask = function InternalRenderTaskClosure() {
|
|
2200
2092
|
return InternalRenderTask;
|
2201
2093
|
}();
|
2202
2094
|
|
2203
|
-
const version = '2.
|
2095
|
+
const version = '2.5.207';
|
2204
2096
|
exports.version = version;
|
2205
|
-
const build = '
|
2097
|
+
const build = '0974d605';
|
2206
2098
|
exports.build = build;
|
@@ -21,27 +21,20 @@
|
|
21
21
|
*/
|
22
22
|
"use strict";
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
} = require("../shared/is_node.js");
|
24
|
+
Object.defineProperty(exports, "__esModule", {
|
25
|
+
value: true
|
26
|
+
});
|
27
|
+
exports.apiCompatibilityParams = void 0;
|
29
28
|
|
30
|
-
|
31
|
-
const isIE = /Trident/.test(userAgent);
|
32
|
-
const isIOSChrome = /CriOS/.test(userAgent);
|
29
|
+
var _is_node = require("../shared/is_node.js");
|
33
30
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
})();
|
39
|
-
|
40
|
-
(function checkFontFaceAndImage() {
|
41
|
-
if (isNodeJS) {
|
31
|
+
const compatibilityParams = Object.create(null);
|
32
|
+
{
|
33
|
+
(function checkFontFace() {
|
34
|
+
if (_is_node.isNodeJS) {
|
42
35
|
compatibilityParams.disableFontFace = true;
|
43
|
-
compatibilityParams.nativeImageDecoderSupport = "none";
|
44
36
|
}
|
45
37
|
})();
|
46
38
|
}
|
47
|
-
|
39
|
+
const apiCompatibilityParams = Object.freeze(compatibilityParams);
|
40
|
+
exports.apiCompatibilityParams = apiCompatibilityParams;
|
package/lib/display/canvas.js
CHANGED
@@ -330,12 +330,12 @@ function compileType3Glyph(imgData) {
|
|
330
330
|
c.translate(0, -height);
|
331
331
|
c.beginPath();
|
332
332
|
|
333
|
-
for (
|
334
|
-
var o = outlines[
|
333
|
+
for (let k = 0, kk = outlines.length; k < kk; k++) {
|
334
|
+
var o = outlines[k];
|
335
335
|
c.moveTo(o[0], o[1]);
|
336
336
|
|
337
|
-
for (
|
338
|
-
c.lineTo(o[
|
337
|
+
for (let l = 2, ll = o.length; l < ll; l += 2) {
|
338
|
+
c.lineTo(o[l], o[l + 1]);
|
339
339
|
}
|
340
340
|
}
|
341
341
|
|
@@ -1287,7 +1287,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1287
1287
|
var fontSize = current.fontSize / current.fontSizeScale;
|
1288
1288
|
var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
|
1289
1289
|
var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
|
1290
|
-
const patternFill = current.patternFill && font.
|
1290
|
+
const patternFill = current.patternFill && !font.missingFile;
|
1291
1291
|
var addToPath;
|
1292
1292
|
|
1293
1293
|
if (font.disableFontFace || isAddToPathSet || patternFill) {
|
@@ -1795,33 +1795,6 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1795
1795
|
endAnnotation: function CanvasGraphics_endAnnotation() {
|
1796
1796
|
this.restore();
|
1797
1797
|
},
|
1798
|
-
paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
|
1799
|
-
const domImage = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
|
1800
|
-
|
1801
|
-
if (!domImage) {
|
1802
|
-
(0, _util.warn)("Dependent image isn't ready yet");
|
1803
|
-
return;
|
1804
|
-
}
|
1805
|
-
|
1806
|
-
this.save();
|
1807
|
-
var ctx = this.ctx;
|
1808
|
-
ctx.scale(1 / w, -1 / h);
|
1809
|
-
ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
|
1810
|
-
|
1811
|
-
if (this.imageLayer) {
|
1812
|
-
var currentTransform = ctx.mozCurrentTransformInverse;
|
1813
|
-
var position = this.getCanvasPosition(0, 0);
|
1814
|
-
this.imageLayer.appendImage({
|
1815
|
-
objId,
|
1816
|
-
left: position[0],
|
1817
|
-
top: position[1],
|
1818
|
-
width: w / currentTransform[0],
|
1819
|
-
height: h / currentTransform[3]
|
1820
|
-
});
|
1821
|
-
}
|
1822
|
-
|
1823
|
-
this.restore();
|
1824
|
-
},
|
1825
1798
|
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
|
1826
1799
|
var ctx = this.ctx;
|
1827
1800
|
var width = img.width,
|
@@ -1905,7 +1878,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1905
1878
|
}
|
1906
1879
|
},
|
1907
1880
|
paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
|
1908
|
-
const imgData =
|
1881
|
+
const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
|
1909
1882
|
|
1910
1883
|
if (!imgData) {
|
1911
1884
|
(0, _util.warn)("Dependent image isn't ready yet");
|
@@ -1915,7 +1888,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1915
1888
|
this.paintInlineImageXObject(imgData);
|
1916
1889
|
},
|
1917
1890
|
paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
|
1918
|
-
const imgData =
|
1891
|
+
const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
|
1919
1892
|
|
1920
1893
|
if (!imgData) {
|
1921
1894
|
(0, _util.warn)("Dependent image isn't ready yet");
|
@@ -99,12 +99,12 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
|
|
99
99
|
return value;
|
100
100
|
}
|
101
101
|
|
102
|
-
function rfc2231getparam(
|
102
|
+
function rfc2231getparam(contentDispositionStr) {
|
103
103
|
const matches = [];
|
104
104
|
let match;
|
105
105
|
const iter = toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)", "ig");
|
106
106
|
|
107
|
-
while ((match = iter.exec(
|
107
|
+
while ((match = iter.exec(contentDispositionStr)) !== null) {
|
108
108
|
let [, n, quot, part] = match;
|
109
109
|
n = parseInt(n, 10);
|
110
110
|
|
@@ -182,10 +182,10 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
|
|
182
182
|
return value;
|
183
183
|
}
|
184
184
|
|
185
|
-
return value.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (
|
185
|
+
return value.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (matches, charset, encoding, text) {
|
186
186
|
if (encoding === "q" || encoding === "Q") {
|
187
187
|
text = text.replace(/_/g, " ");
|
188
|
-
text = text.replace(/=([0-9a-fA-F]{2})/g, function (
|
188
|
+
text = text.replace(/=([0-9a-fA-F]{2})/g, function (match, hex) {
|
189
189
|
return String.fromCharCode(parseInt(hex, 16));
|
190
190
|
});
|
191
191
|
return textdecode(charset, text);
|
@@ -30,7 +30,6 @@ exports.isFetchSupported = isFetchSupported;
|
|
30
30
|
exports.isValidFetchUrl = isValidFetchUrl;
|
31
31
|
exports.loadScript = loadScript;
|
32
32
|
exports.deprecated = deprecated;
|
33
|
-
exports.releaseImageResources = releaseImageResources;
|
34
33
|
exports.PDFDateString = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.RenderingCancelledException = exports.PageViewport = void 0;
|
35
34
|
|
36
35
|
var _util = require("../shared/util.js");
|
@@ -115,9 +114,9 @@ class DOMCMapReaderFactory {
|
|
115
114
|
let cMapData;
|
116
115
|
|
117
116
|
if (this.isCompressed) {
|
118
|
-
cMapData = new Uint8Array(
|
117
|
+
cMapData = new Uint8Array(await response.arrayBuffer());
|
119
118
|
} else {
|
120
|
-
cMapData = (0, _util.stringToBytes)(
|
119
|
+
cMapData = (0, _util.stringToBytes)(await response.text());
|
121
120
|
}
|
122
121
|
|
123
122
|
return {
|
@@ -236,12 +235,15 @@ class PageViewport {
|
|
236
235
|
rotateD = 0;
|
237
236
|
break;
|
238
237
|
|
239
|
-
|
238
|
+
case 0:
|
240
239
|
rotateA = 1;
|
241
240
|
rotateB = 0;
|
242
241
|
rotateC = 0;
|
243
242
|
rotateD = -1;
|
244
243
|
break;
|
244
|
+
|
245
|
+
default:
|
246
|
+
throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.");
|
245
247
|
}
|
246
248
|
|
247
249
|
if (dontFlip) {
|
@@ -462,17 +464,6 @@ function deprecated(details) {
|
|
462
464
|
console.log("Deprecated API usage: " + details);
|
463
465
|
}
|
464
466
|
|
465
|
-
function releaseImageResources(img) {
|
466
|
-
(0, _util.assert)(img instanceof Image, "Invalid `img` parameter.");
|
467
|
-
const url = img.src;
|
468
|
-
|
469
|
-
if (typeof url === "string" && url.startsWith("blob:") && URL.revokeObjectURL) {
|
470
|
-
URL.revokeObjectURL(url);
|
471
|
-
}
|
472
|
-
|
473
|
-
img.removeAttribute("src");
|
474
|
-
}
|
475
|
-
|
476
467
|
let pdfDateStringRegex;
|
477
468
|
|
478
469
|
class PDFDateString {
|
@@ -30,6 +30,8 @@ var _util = require("../shared/util.js");
|
|
30
30
|
|
31
31
|
var _network_utils = require("./network_utils.js");
|
32
32
|
|
33
|
+
;
|
34
|
+
|
33
35
|
function createFetchOptions(headers, withCredentials, abortController) {
|
34
36
|
return {
|
35
37
|
method: "GET",
|
@@ -71,7 +73,7 @@ class PDFFetchStream {
|
|
71
73
|
}
|
72
74
|
|
73
75
|
getFullReader() {
|
74
|
-
(0, _util.assert)(!this._fullRequestReader);
|
76
|
+
(0, _util.assert)(!this._fullRequestReader, "PDFFetchStream.getFullReader can only be called once.");
|
75
77
|
this._fullRequestReader = new PDFFetchStreamReader(this);
|
76
78
|
return this._fullRequestReader;
|
77
79
|
}
|
@@ -90,7 +90,7 @@ class BaseFontLoader {
|
|
90
90
|
await nativeFontFace.loaded;
|
91
91
|
} catch (ex) {
|
92
92
|
this._onUnsupportedFeature({
|
93
|
-
featureId: _util.UNSUPPORTED_FEATURES.
|
93
|
+
featureId: _util.UNSUPPORTED_FEATURES.errorFontLoadNative
|
94
94
|
});
|
95
95
|
|
96
96
|
(0, _util.warn)(`Failed to load font '${nativeFontFace.family}': '${ex}'.`);
|
@@ -357,7 +357,7 @@ class FontFaceObject {
|
|
357
357
|
|
358
358
|
if (this._onUnsupportedFeature) {
|
359
359
|
this._onUnsupportedFeature({
|
360
|
-
featureId: _util.UNSUPPORTED_FEATURES.
|
360
|
+
featureId: _util.UNSUPPORTED_FEATURES.errorFontGetPath
|
361
361
|
});
|
362
362
|
}
|
363
363
|
|
package/lib/display/network.js
CHANGED
@@ -247,7 +247,7 @@ class PDFNetworkStream {
|
|
247
247
|
}
|
248
248
|
|
249
249
|
getFullReader() {
|
250
|
-
(0, _util.assert)(!this._fullRequestReader);
|
250
|
+
(0, _util.assert)(!this._fullRequestReader, "PDFNetworkStream.getFullReader can only be called once.");
|
251
251
|
this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._source);
|
252
252
|
return this._fullRequestReader;
|
253
253
|
}
|
@@ -30,6 +30,8 @@ var _util = require("../shared/util.js");
|
|
30
30
|
|
31
31
|
var _network_utils = require("./network_utils.js");
|
32
32
|
|
33
|
+
;
|
34
|
+
|
33
35
|
const fs = require("fs");
|
34
36
|
|
35
37
|
const http = require("http");
|
@@ -74,7 +76,7 @@ class PDFNodeStream {
|
|
74
76
|
}
|
75
77
|
|
76
78
|
getFullReader() {
|
77
|
-
(0, _util.assert)(!this._fullRequestReader);
|
79
|
+
(0, _util.assert)(!this._fullRequestReader, "PDFNodeStream.getFullReader can only be called once.");
|
78
80
|
this._fullRequestReader = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
|
79
81
|
return this._fullRequestReader;
|
80
82
|
}
|
@@ -321,13 +323,13 @@ class BaseRangeReader {
|
|
321
323
|
|
322
324
|
}
|
323
325
|
|
324
|
-
function createRequestOptions(
|
326
|
+
function createRequestOptions(parsedUrl, headers) {
|
325
327
|
return {
|
326
|
-
protocol:
|
327
|
-
auth:
|
328
|
-
host:
|
329
|
-
port:
|
330
|
-
path:
|
328
|
+
protocol: parsedUrl.protocol,
|
329
|
+
auth: parsedUrl.auth,
|
330
|
+
host: parsedUrl.hostname,
|
331
|
+
port: parsedUrl.port,
|
332
|
+
path: parsedUrl.path,
|
331
333
|
method: "GET",
|
332
334
|
headers
|
333
335
|
};
|
@@ -403,7 +405,7 @@ class PDFNodeStreamRangeReader extends BaseRangeReader {
|
|
403
405
|
this._httpHeaders[property] = value;
|
404
406
|
}
|
405
407
|
|
406
|
-
this._httpHeaders
|
408
|
+
this._httpHeaders.Range = `bytes=${start}-${end - 1}`;
|
407
409
|
|
408
410
|
const handleResponse = response => {
|
409
411
|
if (response.statusCode === 404) {
|