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.

Files changed (133) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +867 -216
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +10214 -8547
  6. package/build/pdf.worker.js.map +1 -1
  7. package/build/pdf.worker.min.js +1 -1
  8. package/es5/build/pdf.js +2023 -1046
  9. package/es5/build/pdf.js.map +1 -1
  10. package/es5/build/pdf.min.js +22 -0
  11. package/es5/build/pdf.worker.js +11136 -8144
  12. package/es5/build/pdf.worker.js.map +1 -1
  13. package/es5/build/pdf.worker.min.js +22 -0
  14. package/es5/image_decoders/pdf.image_decoders.js +12529 -0
  15. package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
  16. package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
  17. package/es5/web/images/shadow.png +0 -0
  18. package/es5/web/pdf_viewer.css +8 -5
  19. package/es5/web/pdf_viewer.js +195 -51
  20. package/es5/web/pdf_viewer.js.map +1 -1
  21. package/image_decoders/pdf.image_decoders.js +24 -16
  22. package/image_decoders/pdf.image_decoders.js.map +1 -1
  23. package/image_decoders/pdf.image_decoders.min.js +1 -1
  24. package/lib/core/annotation.js +479 -43
  25. package/lib/core/cff_parser.js +643 -615
  26. package/lib/core/chunked_stream.js +64 -50
  27. package/lib/core/colorspace.js +126 -104
  28. package/lib/core/crypto.js +37 -0
  29. package/lib/core/document.js +128 -75
  30. package/lib/core/evaluator.js +3015 -2754
  31. package/lib/core/fonts.js +47 -46
  32. package/lib/core/function.js +79 -6
  33. package/lib/core/image.js +364 -357
  34. package/lib/core/image_utils.js +109 -8
  35. package/lib/core/jpg.js +8 -3
  36. package/lib/core/obj.js +255 -34
  37. package/lib/core/operator_list.js +17 -15
  38. package/lib/core/parser.js +40 -3
  39. package/lib/core/pattern.js +24 -11
  40. package/lib/core/primitives.js +112 -53
  41. package/lib/core/type1_parser.js +2 -0
  42. package/lib/core/worker.js +102 -37
  43. package/lib/core/writer.js +242 -0
  44. package/lib/display/annotation_layer.js +51 -10
  45. package/lib/display/annotation_storage.js +89 -0
  46. package/lib/display/api.js +140 -54
  47. package/lib/display/canvas.js +215 -46
  48. package/lib/display/display_utils.js +55 -18
  49. package/lib/display/fetch_stream.js +6 -0
  50. package/lib/display/font_loader.js +26 -15
  51. package/lib/display/metadata.js +1 -7
  52. package/lib/display/network.js +0 -14
  53. package/lib/display/node_utils.js +87 -0
  54. package/lib/display/optional_content_config.js +184 -0
  55. package/lib/display/svg.js +1 -1
  56. package/lib/display/text_layer.js +4 -1
  57. package/lib/pdf.js +2 -2
  58. package/lib/pdf.worker.js +2 -2
  59. package/lib/shared/is_node.js +1 -1
  60. package/lib/shared/util.js +13 -10
  61. package/lib/test/unit/annotation_spec.js +520 -50
  62. package/lib/test/unit/annotation_storage_spec.js +83 -0
  63. package/lib/test/unit/api_spec.js +16 -6
  64. package/lib/test/unit/cmap_spec.js +4 -4
  65. package/lib/test/unit/colorspace_spec.js +216 -24
  66. package/lib/test/unit/crypto_spec.js +51 -4
  67. package/lib/test/unit/custom_spec.js +129 -1
  68. package/lib/test/unit/document_spec.js +112 -1
  69. package/lib/test/unit/evaluator_spec.js +29 -10
  70. package/lib/test/unit/jasmine-boot.js +1 -1
  71. package/lib/test/unit/metadata_spec.js +3 -3
  72. package/lib/test/unit/primitives_spec.js +242 -63
  73. package/lib/test/unit/test_utils.js +42 -89
  74. package/lib/test/unit/testreporter.js +17 -6
  75. package/lib/test/unit/util_spec.js +13 -12
  76. package/lib/test/unit/writer_spec.js +84 -0
  77. package/lib/web/annotation_layer_builder.js +13 -9
  78. package/lib/web/app.js +231 -26
  79. package/lib/web/app_options.js +1 -6
  80. package/lib/web/base_tree_viewer.js +100 -0
  81. package/lib/web/base_viewer.js +53 -4
  82. package/lib/web/download_manager.js +3 -10
  83. package/lib/web/firefox_print_service.js +32 -12
  84. package/lib/web/firefoxcom.js +20 -6
  85. package/lib/web/interfaces.js +1 -1
  86. package/lib/web/pdf_attachment_viewer.js +80 -38
  87. package/lib/web/pdf_find_controller.js +2 -1
  88. package/lib/web/pdf_layer_viewer.js +208 -0
  89. package/lib/web/pdf_outline_viewer.js +24 -57
  90. package/lib/web/pdf_page_view.js +29 -6
  91. package/lib/web/pdf_print_service.js +13 -11
  92. package/lib/web/pdf_sidebar.js +46 -25
  93. package/lib/web/pdf_thumbnail_view.js +16 -3
  94. package/lib/web/pdf_thumbnail_viewer.js +17 -1
  95. package/lib/web/pdf_viewer.component.js +2 -2
  96. package/lib/web/preferences.js +1 -1
  97. package/lib/web/toolbar.js +1 -1
  98. package/lib/web/ui_utils.js +7 -1
  99. package/package.json +3 -1
  100. package/types/display/annotation_layer.d.ts +61 -0
  101. package/types/display/annotation_storage.d.ts +36 -0
  102. package/types/display/api.d.ts +1107 -0
  103. package/types/display/api_compatibility.d.ts +1 -0
  104. package/types/display/canvas.d.ts +4 -0
  105. package/types/display/content_disposition.d.ts +7 -0
  106. package/types/display/display_utils.d.ts +243 -0
  107. package/types/display/fetch_stream.d.ts +67 -0
  108. package/types/display/font_loader.d.ts +19 -0
  109. package/types/display/metadata.d.ts +9 -0
  110. package/types/display/network.d.ts +80 -0
  111. package/types/display/network_utils.d.ts +14 -0
  112. package/types/display/node_stream.d.ts +72 -0
  113. package/types/display/node_utils.d.ts +6 -0
  114. package/types/display/optional_content_config.d.ts +12 -0
  115. package/types/display/pattern_helper.d.ts +5 -0
  116. package/types/display/svg.d.ts +2 -0
  117. package/types/display/text_layer.d.ts +83 -0
  118. package/types/display/transport_stream.d.ts +57 -0
  119. package/types/display/webgl.d.ts +20 -0
  120. package/types/display/worker_options.d.ts +27 -0
  121. package/types/display/xml_parser.d.ts +35 -0
  122. package/types/pdf.d.ts +33 -0
  123. package/types/shared/compatibility.d.ts +1 -0
  124. package/types/shared/is_node.d.ts +1 -0
  125. package/types/shared/message_handler.d.ts +62 -0
  126. package/types/shared/util.d.ts +421 -0
  127. package/web/images/shadow.png +0 -0
  128. package/web/pdf_viewer.css +8 -5
  129. package/web/pdf_viewer.js +109 -33
  130. package/web/pdf_viewer.js.map +1 -1
  131. package/webpack.js +1 -9
  132. package/es5/web/images/texture.png +0 -0
  133. package/web/images/texture.png +0 -0
package/build/pdf.js CHANGED
@@ -325,36 +325,36 @@ var _api = __w_pdfjs_require__(5);
325
325
 
326
326
  var _util = __w_pdfjs_require__(2);
327
327
 
328
- var _annotation_layer = __w_pdfjs_require__(16);
328
+ var _annotation_layer = __w_pdfjs_require__(19);
329
329
 
330
- var _api_compatibility = __w_pdfjs_require__(7);
330
+ var _api_compatibility = __w_pdfjs_require__(9);
331
331
 
332
- var _worker_options = __w_pdfjs_require__(10);
332
+ var _worker_options = __w_pdfjs_require__(12);
333
333
 
334
- var _text_layer = __w_pdfjs_require__(17);
334
+ var _text_layer = __w_pdfjs_require__(20);
335
335
 
336
- var _svg = __w_pdfjs_require__(18);
336
+ var _svg = __w_pdfjs_require__(21);
337
337
 
338
- const pdfjsVersion = '2.5.207';
339
- const pdfjsBuild = '0974d605';
338
+ const pdfjsVersion = '2.6.347';
339
+ const pdfjsBuild = '3be9c65f';
340
340
  {
341
341
  const {
342
342
  isNodeJS
343
343
  } = __w_pdfjs_require__(4);
344
344
 
345
345
  if (isNodeJS) {
346
- const PDFNodeStream = __w_pdfjs_require__(19).PDFNodeStream;
346
+ const PDFNodeStream = __w_pdfjs_require__(22).PDFNodeStream;
347
347
 
348
348
  (0, _api.setPDFNetworkStreamFactory)(params => {
349
349
  return new PDFNodeStream(params);
350
350
  });
351
351
  } else {
352
- const PDFNetworkStream = __w_pdfjs_require__(22).PDFNetworkStream;
352
+ const PDFNetworkStream = __w_pdfjs_require__(25).PDFNetworkStream;
353
353
 
354
354
  let PDFFetchStream;
355
355
 
356
356
  if ((0, _display_utils.isFetchSupported)()) {
357
- PDFFetchStream = __w_pdfjs_require__(23).PDFFetchStream;
357
+ PDFFetchStream = __w_pdfjs_require__(26).PDFFetchStream;
358
358
  }
359
359
 
360
360
  (0, _api.setPDFNetworkStreamFactory)(params => {
@@ -383,7 +383,7 @@ exports.isFetchSupported = isFetchSupported;
383
383
  exports.isValidFetchUrl = isValidFetchUrl;
384
384
  exports.loadScript = loadScript;
385
385
  exports.deprecated = deprecated;
386
- exports.PDFDateString = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.RenderingCancelledException = exports.PageViewport = void 0;
386
+ exports.PDFDateString = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.BaseCMapReaderFactory = exports.DOMCanvasFactory = exports.BaseCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.RenderingCancelledException = exports.PageViewport = void 0;
387
387
 
388
388
  var _util = __w_pdfjs_require__(2);
389
389
 
@@ -391,20 +391,15 @@ const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
391
391
  exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
392
392
  const SVG_NS = "http://www.w3.org/2000/svg";
393
393
 
394
- class DOMCanvasFactory {
395
- create(width, height) {
396
- if (width <= 0 || height <= 0) {
397
- throw new Error("Invalid canvas size");
394
+ class BaseCanvasFactory {
395
+ constructor() {
396
+ if (this.constructor === BaseCanvasFactory) {
397
+ (0, _util.unreachable)("Cannot initialize BaseCanvasFactory.");
398
398
  }
399
+ }
399
400
 
400
- const canvas = document.createElement("canvas");
401
- const context = canvas.getContext("2d");
402
- canvas.width = width;
403
- canvas.height = height;
404
- return {
405
- canvas,
406
- context
407
- };
401
+ create(width, height) {
402
+ (0, _util.unreachable)("Abstract method `create` called.");
408
403
  }
409
404
 
410
405
  reset(canvasAndContext, width, height) {
@@ -433,13 +428,45 @@ class DOMCanvasFactory {
433
428
 
434
429
  }
435
430
 
431
+ exports.BaseCanvasFactory = BaseCanvasFactory;
432
+
433
+ class DOMCanvasFactory extends BaseCanvasFactory {
434
+ constructor({
435
+ ownerDocument = globalThis.document
436
+ } = {}) {
437
+ super();
438
+ this._document = ownerDocument;
439
+ }
440
+
441
+ create(width, height) {
442
+ if (width <= 0 || height <= 0) {
443
+ throw new Error("Invalid canvas size");
444
+ }
445
+
446
+ const canvas = this._document.createElement("canvas");
447
+
448
+ const context = canvas.getContext("2d");
449
+ canvas.width = width;
450
+ canvas.height = height;
451
+ return {
452
+ canvas,
453
+ context
454
+ };
455
+ }
456
+
457
+ }
458
+
436
459
  exports.DOMCanvasFactory = DOMCanvasFactory;
437
460
 
438
- class DOMCMapReaderFactory {
461
+ class BaseCMapReaderFactory {
439
462
  constructor({
440
463
  baseUrl = null,
441
464
  isCompressed = false
442
465
  }) {
466
+ if (this.constructor === BaseCMapReaderFactory) {
467
+ (0, _util.unreachable)("Cannot initialize BaseCMapReaderFactory.");
468
+ }
469
+
443
470
  this.baseUrl = baseUrl;
444
471
  this.isCompressed = isCompressed;
445
472
  }
@@ -457,7 +484,21 @@ class DOMCMapReaderFactory {
457
484
 
458
485
  const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
459
486
  const compressionType = this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE;
487
+ return this._fetchData(url, compressionType).catch(reason => {
488
+ throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${url}`);
489
+ });
490
+ }
491
+
492
+ _fetchData(url, compressionType) {
493
+ (0, _util.unreachable)("Abstract method `_fetchData` called.");
494
+ }
460
495
 
496
+ }
497
+
498
+ exports.BaseCMapReaderFactory = BaseCMapReaderFactory;
499
+
500
+ class DOMCMapReaderFactory extends BaseCMapReaderFactory {
501
+ _fetchData(url, compressionType) {
461
502
  if (isFetchSupported() && isValidFetchUrl(url, document.baseURI)) {
462
503
  return fetch(url).then(async response => {
463
504
  if (!response.ok) {
@@ -476,8 +517,6 @@ class DOMCMapReaderFactory {
476
517
  cMapData,
477
518
  compressionType
478
519
  };
479
- }).catch(reason => {
480
- throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}` + `CMap at: ${url}`);
481
520
  });
482
521
  }
483
522
 
@@ -516,8 +555,6 @@ class DOMCMapReaderFactory {
516
555
  };
517
556
 
518
557
  request.send(null);
519
- }).catch(reason => {
520
- throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}` + `CMap at: ${url}`);
521
558
  });
522
559
  }
523
560
 
@@ -882,12 +919,13 @@ exports.arraysToBytes = arraysToBytes;
882
919
  exports.assert = assert;
883
920
  exports.bytesToString = bytesToString;
884
921
  exports.createPromiseCapability = createPromiseCapability;
922
+ exports.escapeString = escapeString;
923
+ exports.getModificationDate = getModificationDate;
885
924
  exports.getVerbosityLevel = getVerbosityLevel;
886
925
  exports.info = info;
887
926
  exports.isArrayBuffer = isArrayBuffer;
888
927
  exports.isArrayEqual = isArrayEqual;
889
928
  exports.isBool = isBool;
890
- exports.isEmptyObj = isEmptyObj;
891
929
  exports.isNum = isNum;
892
930
  exports.isString = isString;
893
931
  exports.isSameOrigin = isSameOrigin;
@@ -1186,7 +1224,8 @@ const UNSUPPORTED_FEATURES = {
1186
1224
  errorOperatorList: "errorOperatorList",
1187
1225
  errorFontToUnicode: "errorFontToUnicode",
1188
1226
  errorFontLoadNative: "errorFontLoadNative",
1189
- errorFontGetPath: "errorFontGetPath"
1227
+ errorFontGetPath: "errorFontGetPath",
1228
+ errorMarkedContent: "errorMarkedContent"
1190
1229
  };
1191
1230
  exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
1192
1231
  const PasswordResponses = {
@@ -1601,6 +1640,10 @@ function stringToPDFString(str) {
1601
1640
  return strBuf.join("");
1602
1641
  }
1603
1642
 
1643
+ function escapeString(str) {
1644
+ return str.replace(/([\(\)\\])/g, "\\$1");
1645
+ }
1646
+
1604
1647
  function stringToUTF8String(str) {
1605
1648
  return decodeURIComponent(escape(str));
1606
1649
  }
@@ -1609,14 +1652,6 @@ function utf8StringToString(str) {
1609
1652
  return unescape(encodeURIComponent(str));
1610
1653
  }
1611
1654
 
1612
- function isEmptyObj(obj) {
1613
- for (const key in obj) {
1614
- return false;
1615
- }
1616
-
1617
- return true;
1618
- }
1619
-
1620
1655
  function isBool(v) {
1621
1656
  return typeof v === "boolean";
1622
1657
  }
@@ -1643,6 +1678,11 @@ function isArrayEqual(arr1, arr2) {
1643
1678
  });
1644
1679
  }
1645
1680
 
1681
+ function getModificationDate(date = new Date(Date.now())) {
1682
+ const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), (date.getUTCDate() + 1).toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
1683
+ return buffer.join("");
1684
+ }
1685
+
1646
1686
  function createPromiseCapability() {
1647
1687
  const capability = Object.create(null);
1648
1688
  let isSettled = false;
@@ -1717,7 +1757,7 @@ Object.defineProperty(exports, "__esModule", {
1717
1757
  value: true
1718
1758
  });
1719
1759
  exports.isNodeJS = void 0;
1720
- const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !process.versions.electron;
1760
+ const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
1721
1761
  exports.isNodeJS = isNodeJS;
1722
1762
 
1723
1763
  /***/ }),
@@ -1740,24 +1780,32 @@ var _display_utils = __w_pdfjs_require__(1);
1740
1780
 
1741
1781
  var _font_loader = __w_pdfjs_require__(6);
1742
1782
 
1743
- var _api_compatibility = __w_pdfjs_require__(7);
1783
+ var _node_utils = __w_pdfjs_require__(7);
1784
+
1785
+ var _annotation_storage = __w_pdfjs_require__(8);
1744
1786
 
1745
- var _canvas = __w_pdfjs_require__(8);
1787
+ var _api_compatibility = __w_pdfjs_require__(9);
1746
1788
 
1747
- var _worker_options = __w_pdfjs_require__(10);
1789
+ var _canvas = __w_pdfjs_require__(10);
1790
+
1791
+ var _worker_options = __w_pdfjs_require__(12);
1748
1792
 
1749
1793
  var _is_node = __w_pdfjs_require__(4);
1750
1794
 
1751
- var _message_handler = __w_pdfjs_require__(11);
1795
+ var _message_handler = __w_pdfjs_require__(13);
1796
+
1797
+ var _metadata = __w_pdfjs_require__(14);
1752
1798
 
1753
- var _metadata = __w_pdfjs_require__(12);
1799
+ var _optional_content_config = __w_pdfjs_require__(16);
1754
1800
 
1755
- var _transport_stream = __w_pdfjs_require__(14);
1801
+ var _transport_stream = __w_pdfjs_require__(17);
1756
1802
 
1757
- var _webgl = __w_pdfjs_require__(15);
1803
+ var _webgl = __w_pdfjs_require__(18);
1758
1804
 
1759
1805
  const DEFAULT_RANGE_CHUNK_SIZE = 65536;
1760
1806
  const RENDERING_CANCELLED_TIMEOUT = 100;
1807
+ const DefaultCanvasFactory = _is_node.isNodeJS ? _node_utils.NodeCanvasFactory : _display_utils.DOMCanvasFactory;
1808
+ const DefaultCMapReaderFactory = _is_node.isNodeJS ? _node_utils.NodeCMapReaderFactory : _display_utils.DOMCMapReaderFactory;
1761
1809
  let createPDFNetworkStream;
1762
1810
 
1763
1811
  function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
@@ -1826,7 +1874,7 @@ function getDocument(src) {
1826
1874
  }
1827
1875
 
1828
1876
  params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
1829
- params.CMapReaderFactory = params.CMapReaderFactory || _display_utils.DOMCMapReaderFactory;
1877
+ params.CMapReaderFactory = params.CMapReaderFactory || DefaultCMapReaderFactory;
1830
1878
  params.ignoreErrors = params.stopAtErrors !== true;
1831
1879
  params.fontExtraProperties = params.fontExtraProperties === true;
1832
1880
  params.pdfBug = params.pdfBug === true;
@@ -1843,6 +1891,10 @@ function getDocument(src) {
1843
1891
  params.disableFontFace = _api_compatibility.apiCompatibilityParams.disableFontFace || false;
1844
1892
  }
1845
1893
 
1894
+ if (typeof params.ownerDocument === "undefined") {
1895
+ params.ownerDocument = globalThis.document;
1896
+ }
1897
+
1846
1898
  if (typeof params.disableRange !== "boolean") {
1847
1899
  params.disableRange = false;
1848
1900
  }
@@ -1927,7 +1979,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
1927
1979
 
1928
1980
  return worker.messageHandler.sendWithPromise("GetDocRequest", {
1929
1981
  docId,
1930
- apiVersion: '2.5.207',
1982
+ apiVersion: '2.6.347',
1931
1983
  source: {
1932
1984
  data: source.data,
1933
1985
  url: source.url,
@@ -2068,6 +2120,10 @@ class PDFDocumentProxy {
2068
2120
  this._transport = transport;
2069
2121
  }
2070
2122
 
2123
+ get annotationStorage() {
2124
+ return (0, _util.shadow)(this, "annotationStorage", new _annotation_storage.AnnotationStorage());
2125
+ }
2126
+
2071
2127
  get numPages() {
2072
2128
  return this._pdfInfo.numPages;
2073
2129
  }
@@ -2112,13 +2168,6 @@ class PDFDocumentProxy {
2112
2168
  return this._transport.getOpenAction();
2113
2169
  }
2114
2170
 
2115
- getOpenActionDestination() {
2116
- (0, _display_utils.deprecated)("getOpenActionDestination, use getOpenAction instead.");
2117
- return this.getOpenAction().then(function (openAction) {
2118
- return openAction && openAction.dest ? openAction.dest : null;
2119
- });
2120
- }
2121
-
2122
2171
  getAttachments() {
2123
2172
  return this._transport.getAttachments();
2124
2173
  }
@@ -2131,6 +2180,10 @@ class PDFDocumentProxy {
2131
2180
  return this._transport.getOutline();
2132
2181
  }
2133
2182
 
2183
+ getOptionalContentConfig() {
2184
+ return this._transport.getOptionalContentConfig();
2185
+ }
2186
+
2134
2187
  getPermissions() {
2135
2188
  return this._transport.getPermissions();
2136
2189
  }
@@ -2167,14 +2220,19 @@ class PDFDocumentProxy {
2167
2220
  return this._transport.loadingTask;
2168
2221
  }
2169
2222
 
2223
+ saveDocument(annotationStorage) {
2224
+ return this._transport.saveDocument(annotationStorage);
2225
+ }
2226
+
2170
2227
  }
2171
2228
 
2172
2229
  exports.PDFDocumentProxy = PDFDocumentProxy;
2173
2230
 
2174
2231
  class PDFPageProxy {
2175
- constructor(pageIndex, pageInfo, transport, pdfBug = false) {
2232
+ constructor(pageIndex, pageInfo, transport, ownerDocument, pdfBug = false) {
2176
2233
  this._pageIndex = pageIndex;
2177
2234
  this._pageInfo = pageInfo;
2235
+ this._ownerDocument = ownerDocument;
2178
2236
  this._transport = transport;
2179
2237
  this._stats = pdfBug ? new _display_utils.StatTimer() : null;
2180
2238
  this._pdfBug = pdfBug;
@@ -2182,7 +2240,7 @@ class PDFPageProxy {
2182
2240
  this.objs = new PDFObjects();
2183
2241
  this.cleanupAfterRender = false;
2184
2242
  this.pendingCleanup = false;
2185
- this.intentStates = Object.create(null);
2243
+ this._intentStates = new Map();
2186
2244
  this.destroyed = false;
2187
2245
  }
2188
2246
 
@@ -2243,7 +2301,9 @@ class PDFPageProxy {
2243
2301
  transform = null,
2244
2302
  imageLayer = null,
2245
2303
  canvasFactory = null,
2246
- background = null
2304
+ background = null,
2305
+ annotationStorage = null,
2306
+ optionalContentConfigPromise = null
2247
2307
  }) {
2248
2308
  if (this._stats) {
2249
2309
  this._stats.time("Overall");
@@ -2252,18 +2312,26 @@ class PDFPageProxy {
2252
2312
  const renderingIntent = intent === "print" ? "print" : "display";
2253
2313
  this.pendingCleanup = false;
2254
2314
 
2255
- if (!this.intentStates[renderingIntent]) {
2256
- this.intentStates[renderingIntent] = Object.create(null);
2315
+ if (!optionalContentConfigPromise) {
2316
+ optionalContentConfigPromise = this._transport.getOptionalContentConfig();
2257
2317
  }
2258
2318
 
2259
- const intentState = this.intentStates[renderingIntent];
2319
+ let intentState = this._intentStates.get(renderingIntent);
2320
+
2321
+ if (!intentState) {
2322
+ intentState = Object.create(null);
2323
+
2324
+ this._intentStates.set(renderingIntent, intentState);
2325
+ }
2260
2326
 
2261
2327
  if (intentState.streamReaderCancelTimeout) {
2262
2328
  clearTimeout(intentState.streamReaderCancelTimeout);
2263
2329
  intentState.streamReaderCancelTimeout = null;
2264
2330
  }
2265
2331
 
2266
- const canvasFactoryInstance = canvasFactory || new _display_utils.DOMCanvasFactory();
2332
+ const canvasFactoryInstance = canvasFactory || new DefaultCanvasFactory({
2333
+ ownerDocument: this._ownerDocument
2334
+ });
2267
2335
  const webGLContext = new _webgl.WebGLContext({
2268
2336
  enable: enableWebGL
2269
2337
  });
@@ -2283,7 +2351,8 @@ class PDFPageProxy {
2283
2351
  this._pumpOperatorList({
2284
2352
  pageIndex: this._pageIndex,
2285
2353
  intent: renderingIntent,
2286
- renderInteractiveForms: renderInteractiveForms === true
2354
+ renderInteractiveForms: renderInteractiveForms === true,
2355
+ annotationStorage: annotationStorage && annotationStorage.getAll() || null
2287
2356
  });
2288
2357
  }
2289
2358
 
@@ -2343,7 +2412,7 @@ class PDFPageProxy {
2343
2412
 
2344
2413
  intentState.renderTasks.push(internalRenderTask);
2345
2414
  const renderTask = internalRenderTask.task;
2346
- intentState.displayReadyCapability.promise.then(transparency => {
2415
+ Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(([transparency, optionalContentConfig]) => {
2347
2416
  if (this.pendingCleanup) {
2348
2417
  complete();
2349
2418
  return;
@@ -2353,7 +2422,10 @@ class PDFPageProxy {
2353
2422
  this._stats.time("Rendering");
2354
2423
  }
2355
2424
 
2356
- internalRenderTask.initializeGraphics(transparency);
2425
+ internalRenderTask.initializeGraphics({
2426
+ transparency,
2427
+ optionalContentConfig
2428
+ });
2357
2429
  internalRenderTask.operatorListChanged();
2358
2430
  }).catch(complete);
2359
2431
  return renderTask;
@@ -2373,15 +2445,18 @@ class PDFPageProxy {
2373
2445
 
2374
2446
  const renderingIntent = "oplist";
2375
2447
 
2376
- if (!this.intentStates[renderingIntent]) {
2377
- this.intentStates[renderingIntent] = Object.create(null);
2448
+ let intentState = this._intentStates.get(renderingIntent);
2449
+
2450
+ if (!intentState) {
2451
+ intentState = Object.create(null);
2452
+
2453
+ this._intentStates.set(renderingIntent, intentState);
2378
2454
  }
2379
2455
 
2380
- const intentState = this.intentStates[renderingIntent];
2381
2456
  let opListTask;
2382
2457
 
2383
2458
  if (!intentState.opListReadCapability) {
2384
- opListTask = {};
2459
+ opListTask = Object.create(null);
2385
2460
  opListTask.operatorListChanged = operatorListChanged;
2386
2461
  intentState.opListReadCapability = (0, _util.createPromiseCapability)();
2387
2462
  intentState.renderTasks = [];
@@ -2456,9 +2531,8 @@ class PDFPageProxy {
2456
2531
  this.destroyed = true;
2457
2532
  this._transport.pageCache[this._pageIndex] = null;
2458
2533
  const waitOn = [];
2459
- Object.keys(this.intentStates).forEach(intent => {
2460
- const intentState = this.intentStates[intent];
2461
2534
 
2535
+ for (const [intent, intentState] of this._intentStates) {
2462
2536
  this._abortOperatorList({
2463
2537
  intentState,
2464
2538
  reason: new Error("Page was destroyed."),
@@ -2466,15 +2540,15 @@ class PDFPageProxy {
2466
2540
  });
2467
2541
 
2468
2542
  if (intent === "oplist") {
2469
- return;
2543
+ continue;
2470
2544
  }
2471
2545
 
2472
- intentState.renderTasks.forEach(function (renderTask) {
2473
- const renderCompleted = renderTask.capability.promise.catch(function () {});
2474
- waitOn.push(renderCompleted);
2475
- renderTask.cancel();
2476
- });
2477
- });
2546
+ for (const internalRenderTask of intentState.renderTasks) {
2547
+ waitOn.push(internalRenderTask.completed);
2548
+ internalRenderTask.cancel();
2549
+ }
2550
+ }
2551
+
2478
2552
  this.objs.clear();
2479
2553
  this.annotationsPromise = null;
2480
2554
  this.pendingCleanup = false;
@@ -2487,16 +2561,21 @@ class PDFPageProxy {
2487
2561
  }
2488
2562
 
2489
2563
  _tryCleanup(resetStats = false) {
2490
- if (!this.pendingCleanup || Object.keys(this.intentStates).some(intent => {
2491
- const intentState = this.intentStates[intent];
2492
- return intentState.renderTasks.length !== 0 || !intentState.operatorList.lastChunk;
2493
- })) {
2564
+ if (!this.pendingCleanup) {
2494
2565
  return false;
2495
2566
  }
2496
2567
 
2497
- Object.keys(this.intentStates).forEach(intent => {
2498
- delete this.intentStates[intent];
2499
- });
2568
+ for (const {
2569
+ renderTasks,
2570
+ operatorList
2571
+ } of this._intentStates.values()) {
2572
+ if (renderTasks.length !== 0 || !operatorList.lastChunk) {
2573
+ return false;
2574
+ }
2575
+ }
2576
+
2577
+ this._intentStates.clear();
2578
+
2500
2579
  this.objs.clear();
2501
2580
  this.annotationsPromise = null;
2502
2581
 
@@ -2509,7 +2588,7 @@ class PDFPageProxy {
2509
2588
  }
2510
2589
 
2511
2590
  _startRenderPage(transparency, intent) {
2512
- const intentState = this.intentStates[intent];
2591
+ const intentState = this._intentStates.get(intent);
2513
2592
 
2514
2593
  if (!intentState) {
2515
2594
  return;
@@ -2547,7 +2626,9 @@ class PDFPageProxy {
2547
2626
  const readableStream = this._transport.messageHandler.sendWithStream("GetOperatorList", args);
2548
2627
 
2549
2628
  const reader = readableStream.getReader();
2550
- const intentState = this.intentStates[args.intent];
2629
+
2630
+ const intentState = this._intentStates.get(args.intent);
2631
+
2551
2632
  intentState.streamReader = reader;
2552
2633
 
2553
2634
  const pump = () => {
@@ -2634,14 +2715,14 @@ class PDFPageProxy {
2634
2715
  return;
2635
2716
  }
2636
2717
 
2637
- Object.keys(this.intentStates).some(intent => {
2638
- if (this.intentStates[intent] === intentState) {
2639
- delete this.intentStates[intent];
2640
- return true;
2718
+ for (const [intent, curIntentState] of this._intentStates) {
2719
+ if (curIntentState === intentState) {
2720
+ this._intentStates.delete(intent);
2721
+
2722
+ break;
2641
2723
  }
2724
+ }
2642
2725
 
2643
- return false;
2644
- });
2645
2726
  this.cleanup();
2646
2727
  }
2647
2728
 
@@ -3058,7 +3139,8 @@ class WorkerTransport {
3058
3139
  this.commonObjs = new PDFObjects();
3059
3140
  this.fontLoader = new _font_loader.FontLoader({
3060
3141
  docId: loadingTask.docId,
3061
- onUnsupportedFeature: this._onUnsupportedFeature.bind(this)
3142
+ onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
3143
+ ownerDocument: params.ownerDocument
3062
3144
  });
3063
3145
  this._params = params;
3064
3146
  this.CMapReaderFactory = new params.CMapReaderFactory({
@@ -3151,6 +3233,14 @@ class WorkerTransport {
3151
3233
 
3152
3234
  sink.onCancel = reason => {
3153
3235
  this._fullReader.cancel(reason);
3236
+
3237
+ sink.ready.catch(readyReason => {
3238
+ if (this.destroyed) {
3239
+ return;
3240
+ }
3241
+
3242
+ throw readyReason;
3243
+ });
3154
3244
  };
3155
3245
  });
3156
3246
  messageHandler.on("ReaderHeadersReady", data => {
@@ -3209,6 +3299,13 @@ class WorkerTransport {
3209
3299
 
3210
3300
  sink.onCancel = reason => {
3211
3301
  rangeReader.cancel(reason);
3302
+ sink.ready.catch(readyReason => {
3303
+ if (this.destroyed) {
3304
+ return;
3305
+ }
3306
+
3307
+ throw readyReason;
3308
+ });
3212
3309
  };
3213
3310
  });
3214
3311
  messageHandler.on("GetDoc", ({
@@ -3243,6 +3340,11 @@ class WorkerTransport {
3243
3340
  break;
3244
3341
  }
3245
3342
 
3343
+ if (!(reason instanceof Error)) {
3344
+ const msg = "DocException - expected a valid Error.";
3345
+ (0, _util.warn)(msg);
3346
+ }
3347
+
3246
3348
  loadingTask._capability.reject(reason);
3247
3349
  });
3248
3350
  messageHandler.on("PasswordRequest", exception => {
@@ -3339,7 +3441,6 @@ class WorkerTransport {
3339
3441
  break;
3340
3442
 
3341
3443
  case "FontPath":
3342
- case "FontType3Res":
3343
3444
  case "Image":
3344
3445
  this.commonObjs.resolve(id, exportedData);
3345
3446
  break;
@@ -3448,7 +3549,7 @@ class WorkerTransport {
3448
3549
  throw new Error("Transport destroyed");
3449
3550
  }
3450
3551
 
3451
- const page = new PDFPageProxy(pageIndex, pageInfo, this, this._params.pdfBug);
3552
+ const page = new PDFPageProxy(pageIndex, pageInfo, this, this._params.ownerDocument, this._params.pdfBug);
3452
3553
  this.pageCache[pageIndex] = page;
3453
3554
  return page;
3454
3555
  });
@@ -3471,6 +3572,18 @@ class WorkerTransport {
3471
3572
  });
3472
3573
  }
3473
3574
 
3575
+ saveDocument(annotationStorage) {
3576
+ return this.messageHandler.sendWithPromise("SaveDocument", {
3577
+ numPages: this._numPages,
3578
+ annotationStorage: annotationStorage && annotationStorage.getAll() || null,
3579
+ filename: this._fullReader ? this._fullReader.filename : null
3580
+ }).finally(() => {
3581
+ if (annotationStorage) {
3582
+ annotationStorage.resetModified();
3583
+ }
3584
+ });
3585
+ }
3586
+
3474
3587
  getDestinations() {
3475
3588
  return this.messageHandler.sendWithPromise("GetDestinations", null);
3476
3589
  }
@@ -3517,6 +3630,12 @@ class WorkerTransport {
3517
3630
  return this.messageHandler.sendWithPromise("GetOutline", null);
3518
3631
  }
3519
3632
 
3633
+ getOptionalContentConfig() {
3634
+ return this.messageHandler.sendWithPromise("GetOptionalContentConfig", null).then(results => {
3635
+ return new _optional_content_config.OptionalContentConfig(results);
3636
+ });
3637
+ }
3638
+
3520
3639
  getPermissions() {
3521
3640
  return this.messageHandler.sendWithPromise("GetPermissions", null);
3522
3641
  }
@@ -3671,7 +3790,14 @@ const InternalRenderTask = function InternalRenderTaskClosure() {
3671
3790
  this._canvas = params.canvasContext.canvas;
3672
3791
  }
3673
3792
 
3674
- initializeGraphics(transparency = false) {
3793
+ get completed() {
3794
+ return this.capability.promise.catch(function () {});
3795
+ }
3796
+
3797
+ initializeGraphics({
3798
+ transparency = false,
3799
+ optionalContentConfig
3800
+ }) {
3675
3801
  if (this.cancelled) {
3676
3802
  return;
3677
3803
  }
@@ -3697,7 +3823,7 @@ const InternalRenderTask = function InternalRenderTaskClosure() {
3697
3823
  imageLayer,
3698
3824
  background
3699
3825
  } = this.params;
3700
- this.gfx = new _canvas.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext, imageLayer);
3826
+ this.gfx = new _canvas.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext, imageLayer, optionalContentConfig);
3701
3827
  this.gfx.beginDrawing({
3702
3828
  transform,
3703
3829
  viewport,
@@ -3798,9 +3924,9 @@ const InternalRenderTask = function InternalRenderTaskClosure() {
3798
3924
  return InternalRenderTask;
3799
3925
  }();
3800
3926
 
3801
- const version = '2.5.207';
3927
+ const version = '2.6.347';
3802
3928
  exports.version = version;
3803
- const build = '0974d605';
3929
+ const build = '3be9c65f';
3804
3930
  exports.build = build;
3805
3931
 
3806
3932
  /***/ }),
@@ -3820,7 +3946,8 @@ var _util = __w_pdfjs_require__(2);
3820
3946
  class BaseFontLoader {
3821
3947
  constructor({
3822
3948
  docId,
3823
- onUnsupportedFeature
3949
+ onUnsupportedFeature,
3950
+ ownerDocument = globalThis.document
3824
3951
  }) {
3825
3952
  if (this.constructor === BaseFontLoader) {
3826
3953
  (0, _util.unreachable)("Cannot initialize BaseFontLoader.");
@@ -3828,22 +3955,25 @@ class BaseFontLoader {
3828
3955
 
3829
3956
  this.docId = docId;
3830
3957
  this._onUnsupportedFeature = onUnsupportedFeature;
3958
+ this._document = ownerDocument;
3831
3959
  this.nativeFontFaces = [];
3832
3960
  this.styleElement = null;
3833
3961
  }
3834
3962
 
3835
3963
  addNativeFontFace(nativeFontFace) {
3836
3964
  this.nativeFontFaces.push(nativeFontFace);
3837
- document.fonts.add(nativeFontFace);
3965
+
3966
+ this._document.fonts.add(nativeFontFace);
3838
3967
  }
3839
3968
 
3840
3969
  insertRule(rule) {
3841
3970
  let styleElement = this.styleElement;
3842
3971
 
3843
3972
  if (!styleElement) {
3844
- styleElement = this.styleElement = document.createElement("style");
3973
+ styleElement = this.styleElement = this._document.createElement("style");
3845
3974
  styleElement.id = `PDFJS_FONT_STYLE_TAG_${this.docId}`;
3846
- document.documentElement.getElementsByTagName("head")[0].appendChild(styleElement);
3975
+
3976
+ this._document.documentElement.getElementsByTagName("head")[0].appendChild(styleElement);
3847
3977
  }
3848
3978
 
3849
3979
  const styleSheet = styleElement.sheet;
@@ -3851,8 +3981,8 @@ class BaseFontLoader {
3851
3981
  }
3852
3982
 
3853
3983
  clear() {
3854
- this.nativeFontFaces.forEach(function (nativeFontFace) {
3855
- document.fonts.delete(nativeFontFace);
3984
+ this.nativeFontFaces.forEach(nativeFontFace => {
3985
+ this._document.fonts.delete(nativeFontFace);
3856
3986
  });
3857
3987
  this.nativeFontFaces.length = 0;
3858
3988
 
@@ -3913,7 +4043,7 @@ class BaseFontLoader {
3913
4043
  }
3914
4044
 
3915
4045
  get isFontLoadingAPISupported() {
3916
- const supported = typeof document !== "undefined" && !!document.fonts;
4046
+ const supported = typeof this._document !== "undefined" && !!this._document.fonts;
3917
4047
  return (0, _util.shadow)(this, "isFontLoadingAPISupported", supported);
3918
4048
  }
3919
4049
 
@@ -3935,8 +4065,8 @@ let FontLoader;
3935
4065
  exports.FontLoader = FontLoader;
3936
4066
  {
3937
4067
  exports.FontLoader = FontLoader = class GenericFontLoader extends BaseFontLoader {
3938
- constructor(docId) {
3939
- super(docId);
4068
+ constructor(params) {
4069
+ super(params);
3940
4070
  this.loadingContext = {
3941
4071
  requests: [],
3942
4072
  nextRequestId: 0
@@ -4002,7 +4132,9 @@ exports.FontLoader = FontLoader;
4002
4132
  }
4003
4133
 
4004
4134
  let i, ii;
4005
- const canvas = document.createElement("canvas");
4135
+
4136
+ const canvas = this._document.createElement("canvas");
4137
+
4006
4138
  canvas.width = 1;
4007
4139
  canvas.height = 1;
4008
4140
  const ctx = canvas.getContext("2d");
@@ -4056,22 +4188,27 @@ exports.FontLoader = FontLoader;
4056
4188
  }
4057
4189
 
4058
4190
  names.push(loadTestFontId);
4059
- const div = document.createElement("div");
4191
+
4192
+ const div = this._document.createElement("div");
4193
+
4060
4194
  div.style.visibility = "hidden";
4061
4195
  div.style.width = div.style.height = "10px";
4062
4196
  div.style.position = "absolute";
4063
4197
  div.style.top = div.style.left = "0px";
4064
4198
 
4065
4199
  for (i = 0, ii = names.length; i < ii; ++i) {
4066
- const span = document.createElement("span");
4200
+ const span = this._document.createElement("span");
4201
+
4067
4202
  span.textContent = "Hi";
4068
4203
  span.style.fontFamily = names[i];
4069
4204
  div.appendChild(span);
4070
4205
  }
4071
4206
 
4072
- document.body.appendChild(div);
4073
- isFontReady(loadTestFontId, function () {
4074
- document.body.removeChild(div);
4207
+ this._document.body.appendChild(div);
4208
+
4209
+ isFontReady(loadTestFontId, () => {
4210
+ this._document.body.removeChild(div);
4211
+
4075
4212
  request.complete();
4076
4213
  });
4077
4214
  }
@@ -4197,6 +4334,152 @@ exports.FontFaceObject = FontFaceObject;
4197
4334
  "use strict";
4198
4335
 
4199
4336
 
4337
+ Object.defineProperty(exports, "__esModule", {
4338
+ value: true
4339
+ });
4340
+ exports.NodeCMapReaderFactory = exports.NodeCanvasFactory = void 0;
4341
+
4342
+ var _display_utils = __w_pdfjs_require__(1);
4343
+
4344
+ var _is_node = __w_pdfjs_require__(4);
4345
+
4346
+ var _util = __w_pdfjs_require__(2);
4347
+
4348
+ let NodeCanvasFactory = class {
4349
+ constructor() {
4350
+ (0, _util.unreachable)("Not implemented: NodeCanvasFactory");
4351
+ }
4352
+
4353
+ };
4354
+ exports.NodeCanvasFactory = NodeCanvasFactory;
4355
+ let NodeCMapReaderFactory = class {
4356
+ constructor() {
4357
+ (0, _util.unreachable)("Not implemented: NodeCMapReaderFactory");
4358
+ }
4359
+
4360
+ };
4361
+ exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
4362
+
4363
+ if (_is_node.isNodeJS) {
4364
+ exports.NodeCanvasFactory = NodeCanvasFactory = class extends _display_utils.BaseCanvasFactory {
4365
+ create(width, height) {
4366
+ if (width <= 0 || height <= 0) {
4367
+ throw new Error("Invalid canvas size");
4368
+ }
4369
+
4370
+ const Canvas = require("canvas");
4371
+
4372
+ const canvas = Canvas.createCanvas(width, height);
4373
+ return {
4374
+ canvas,
4375
+ context: canvas.getContext("2d")
4376
+ };
4377
+ }
4378
+
4379
+ };
4380
+ exports.NodeCMapReaderFactory = NodeCMapReaderFactory = class extends _display_utils.BaseCMapReaderFactory {
4381
+ _fetchData(url, compressionType) {
4382
+ return new Promise((resolve, reject) => {
4383
+ const fs = require("fs");
4384
+
4385
+ fs.readFile(url, (error, data) => {
4386
+ if (error || !data) {
4387
+ reject(new Error(error));
4388
+ return;
4389
+ }
4390
+
4391
+ resolve({
4392
+ cMapData: new Uint8Array(data),
4393
+ compressionType
4394
+ });
4395
+ });
4396
+ });
4397
+ }
4398
+
4399
+ };
4400
+ }
4401
+
4402
+ /***/ }),
4403
+ /* 8 */
4404
+ /***/ (function(module, exports, __w_pdfjs_require__) {
4405
+
4406
+ "use strict";
4407
+
4408
+
4409
+ Object.defineProperty(exports, "__esModule", {
4410
+ value: true
4411
+ });
4412
+ exports.AnnotationStorage = void 0;
4413
+
4414
+ class AnnotationStorage {
4415
+ constructor() {
4416
+ this._storage = new Map();
4417
+ this._modified = false;
4418
+ this.onSetModified = null;
4419
+ this.onResetModified = null;
4420
+ }
4421
+
4422
+ getOrCreateValue(key, defaultValue) {
4423
+ if (this._storage.has(key)) {
4424
+ return this._storage.get(key);
4425
+ }
4426
+
4427
+ this._storage.set(key, defaultValue);
4428
+
4429
+ return defaultValue;
4430
+ }
4431
+
4432
+ setValue(key, value) {
4433
+ if (this._storage.get(key) !== value) {
4434
+ this._setModified();
4435
+ }
4436
+
4437
+ this._storage.set(key, value);
4438
+ }
4439
+
4440
+ getAll() {
4441
+ if (this._storage.size === 0) {
4442
+ return null;
4443
+ }
4444
+
4445
+ return Object.fromEntries(this._storage);
4446
+ }
4447
+
4448
+ get size() {
4449
+ return this._storage.size;
4450
+ }
4451
+
4452
+ _setModified() {
4453
+ if (!this._modified) {
4454
+ this._modified = true;
4455
+
4456
+ if (typeof this.onSetModified === "function") {
4457
+ this.onSetModified();
4458
+ }
4459
+ }
4460
+ }
4461
+
4462
+ resetModified() {
4463
+ if (this._modified) {
4464
+ this._modified = false;
4465
+
4466
+ if (typeof this.onResetModified === "function") {
4467
+ this.onResetModified();
4468
+ }
4469
+ }
4470
+ }
4471
+
4472
+ }
4473
+
4474
+ exports.AnnotationStorage = AnnotationStorage;
4475
+
4476
+ /***/ }),
4477
+ /* 9 */
4478
+ /***/ (function(module, exports, __w_pdfjs_require__) {
4479
+
4480
+ "use strict";
4481
+
4482
+
4200
4483
  Object.defineProperty(exports, "__esModule", {
4201
4484
  value: true
4202
4485
  });
@@ -4216,7 +4499,7 @@ const apiCompatibilityParams = Object.freeze(compatibilityParams);
4216
4499
  exports.apiCompatibilityParams = apiCompatibilityParams;
4217
4500
 
4218
4501
  /***/ }),
4219
- /* 8 */
4502
+ /* 10 */
4220
4503
  /***/ (function(module, exports, __w_pdfjs_require__) {
4221
4504
 
4222
4505
  "use strict";
@@ -4229,7 +4512,7 @@ exports.CanvasGraphics = void 0;
4229
4512
 
4230
4513
  var _util = __w_pdfjs_require__(2);
4231
4514
 
4232
- var _pattern_helper = __w_pdfjs_require__(9);
4515
+ var _pattern_helper = __w_pdfjs_require__(11);
4233
4516
 
4234
4517
  var MIN_FONT_SIZE = 16;
4235
4518
  var MAX_FONT_SIZE = 100;
@@ -4574,6 +4857,7 @@ var CanvasExtraState = function CanvasExtraStateClosure() {
4574
4857
  this.lineWidth = 1;
4575
4858
  this.activeSMask = null;
4576
4859
  this.resumeSMaskCtx = null;
4860
+ this.transferMaps = null;
4577
4861
  }
4578
4862
 
4579
4863
  CanvasExtraState.prototype = {
@@ -4592,7 +4876,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
4592
4876
  var EXECUTION_TIME = 15;
4593
4877
  var EXECUTION_STEPS = 10;
4594
4878
 
4595
- function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer) {
4879
+ function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer, optionalContentConfig) {
4596
4880
  this.ctx = canvasCtx;
4597
4881
  this.current = new CanvasExtraState();
4598
4882
  this.stateStack = [];
@@ -4613,6 +4897,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
4613
4897
  this.smaskStack = [];
4614
4898
  this.smaskCounter = 0;
4615
4899
  this.tempSMask = null;
4900
+ this.contentVisible = true;
4901
+ this.markedContentStack = [];
4902
+ this.optionalContentConfig = optionalContentConfig;
4616
4903
  this.cachedCanvases = new CachedCanvases(this.canvasFactory);
4617
4904
 
4618
4905
  if (canvasCtx) {
@@ -4622,7 +4909,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
4622
4909
  this._cachedGetSinglePixelWidth = null;
4623
4910
  }
4624
4911
 
4625
- function putBinaryImageData(ctx, imgData) {
4912
+ function putBinaryImageData(ctx, imgData, transferMaps = null) {
4626
4913
  if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
4627
4914
  ctx.putImageData(imgData, 0, 0);
4628
4915
  return;
@@ -4639,6 +4926,25 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
4639
4926
  var src = imgData.data;
4640
4927
  var dest = chunkImgData.data;
4641
4928
  var i, j, thisChunkHeight, elemsInThisChunk;
4929
+ let transferMapRed, transferMapGreen, transferMapBlue, transferMapGray;
4930
+
4931
+ if (transferMaps) {
4932
+ switch (transferMaps.length) {
4933
+ case 1:
4934
+ transferMapRed = transferMaps[0];
4935
+ transferMapGreen = transferMaps[0];
4936
+ transferMapBlue = transferMaps[0];
4937
+ transferMapGray = transferMaps[0];
4938
+ break;
4939
+
4940
+ case 4:
4941
+ transferMapRed = transferMaps[0];
4942
+ transferMapGreen = transferMaps[1];
4943
+ transferMapBlue = transferMaps[2];
4944
+ transferMapGray = transferMaps[3];
4945
+ break;
4946
+ }
4947
+ }
4642
4948
 
4643
4949
  if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
4644
4950
  var srcLength = src.byteLength;
@@ -4648,13 +4954,19 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
4648
4954
  var white = 0xffffffff;
4649
4955
  var black = _util.IsLittleEndianCached.value ? 0xff000000 : 0x000000ff;
4650
4956
 
4957
+ if (transferMapGray) {
4958
+ if (transferMapGray[0] === 0xff && transferMapGray[0xff] === 0) {
4959
+ [white, black] = [black, white];
4960
+ }
4961
+ }
4962
+
4651
4963
  for (i = 0; i < totalChunks; i++) {
4652
4964
  thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
4653
4965
  destPos = 0;
4654
4966
 
4655
4967
  for (j = 0; j < thisChunkHeight; j++) {
4656
4968
  var srcDiff = srcLength - srcPos;
4657
- var k = 0;
4969
+ let k = 0;
4658
4970
  var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
4659
4971
  var kEndUnrolled = kEnd & ~7;
4660
4972
  var mask = 0;
@@ -4690,12 +5002,30 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
4690
5002
  ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
4691
5003
  }
4692
5004
  } else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
5005
+ const hasTransferMaps = !!(transferMapRed || transferMapGreen || transferMapBlue);
4693
5006
  j = 0;
4694
5007
  elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
4695
5008
 
4696
5009
  for (i = 0; i < fullChunks; i++) {
4697
5010
  dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
4698
5011
  srcPos += elemsInThisChunk;
5012
+
5013
+ if (hasTransferMaps) {
5014
+ for (let k = 0; k < elemsInThisChunk; k += 4) {
5015
+ if (transferMapRed) {
5016
+ dest[k + 0] = transferMapRed[dest[k + 0]];
5017
+ }
5018
+
5019
+ if (transferMapGreen) {
5020
+ dest[k + 1] = transferMapGreen[dest[k + 1]];
5021
+ }
5022
+
5023
+ if (transferMapBlue) {
5024
+ dest[k + 2] = transferMapBlue[dest[k + 2]];
5025
+ }
5026
+ }
5027
+ }
5028
+
4699
5029
  ctx.putImageData(chunkImgData, 0, j);
4700
5030
  j += FULL_CHUNK_HEIGHT;
4701
5031
  }
@@ -4703,9 +5033,27 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
4703
5033
  if (i < totalChunks) {
4704
5034
  elemsInThisChunk = width * partialChunkHeight * 4;
4705
5035
  dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
5036
+
5037
+ if (hasTransferMaps) {
5038
+ for (let k = 0; k < elemsInThisChunk; k += 4) {
5039
+ if (transferMapRed) {
5040
+ dest[k + 0] = transferMapRed[dest[k + 0]];
5041
+ }
5042
+
5043
+ if (transferMapGreen) {
5044
+ dest[k + 1] = transferMapGreen[dest[k + 1]];
5045
+ }
5046
+
5047
+ if (transferMapBlue) {
5048
+ dest[k + 2] = transferMapBlue[dest[k + 2]];
5049
+ }
5050
+ }
5051
+ }
5052
+
4706
5053
  ctx.putImageData(chunkImgData, 0, j);
4707
5054
  }
4708
5055
  } else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
5056
+ const hasTransferMaps = !!(transferMapRed || transferMapGreen || transferMapBlue);
4709
5057
  thisChunkHeight = FULL_CHUNK_HEIGHT;
4710
5058
  elemsInThisChunk = width * thisChunkHeight;
4711
5059
 
@@ -4724,6 +5072,22 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
4724
5072
  dest[destPos++] = 255;
4725
5073
  }
4726
5074
 
5075
+ if (hasTransferMaps) {
5076
+ for (let k = 0; k < destPos; k += 4) {
5077
+ if (transferMapRed) {
5078
+ dest[k + 0] = transferMapRed[dest[k + 0]];
5079
+ }
5080
+
5081
+ if (transferMapGreen) {
5082
+ dest[k + 1] = transferMapGreen[dest[k + 1]];
5083
+ }
5084
+
5085
+ if (transferMapBlue) {
5086
+ dest[k + 2] = transferMapBlue[dest[k + 2]];
5087
+ }
5088
+ }
5089
+ }
5090
+
4727
5091
  ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
4728
5092
  }
4729
5093
  } else {
@@ -5106,6 +5470,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
5106
5470
 
5107
5471
  this.tempSMask = null;
5108
5472
  break;
5473
+
5474
+ case "TR":
5475
+ this.current.transferMaps = value;
5109
5476
  }
5110
5477
  }
5111
5478
  },
@@ -5207,22 +5574,22 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
5207
5574
  var width = args[j++];
5208
5575
  var height = args[j++];
5209
5576
 
5210
- if (width === 0) {
5577
+ if (width === 0 && ctx.lineWidth < this.getSinglePixelWidth()) {
5211
5578
  width = this.getSinglePixelWidth();
5212
5579
  }
5213
5580
 
5214
- if (height === 0) {
5581
+ if (height === 0 && ctx.lineWidth < this.getSinglePixelWidth()) {
5215
5582
  height = this.getSinglePixelWidth();
5216
5583
  }
5217
5584
 
5218
5585
  var xw = x + width;
5219
5586
  var yh = y + height;
5220
- this.ctx.moveTo(x, y);
5221
- this.ctx.lineTo(xw, y);
5222
- this.ctx.lineTo(xw, yh);
5223
- this.ctx.lineTo(x, yh);
5224
- this.ctx.lineTo(x, y);
5225
- this.ctx.closePath();
5587
+ ctx.moveTo(x, y);
5588
+ ctx.lineTo(xw, y);
5589
+ ctx.lineTo(xw, yh);
5590
+ ctx.lineTo(x, yh);
5591
+ ctx.lineTo(x, y);
5592
+ ctx.closePath();
5226
5593
  break;
5227
5594
 
5228
5595
  case _util.OPS.moveTo:
@@ -5275,19 +5642,21 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
5275
5642
  var strokeColor = this.current.strokeColor;
5276
5643
  ctx.globalAlpha = this.current.strokeAlpha;
5277
5644
 
5278
- if (strokeColor && strokeColor.hasOwnProperty("type") && strokeColor.type === "Pattern") {
5279
- ctx.save();
5280
- const transform = ctx.mozCurrentTransform;
5645
+ if (this.contentVisible) {
5646
+ if (strokeColor && strokeColor.hasOwnProperty("type") && strokeColor.type === "Pattern") {
5647
+ ctx.save();
5648
+ const transform = ctx.mozCurrentTransform;
5281
5649
 
5282
- const scale = _util.Util.singularValueDecompose2dScale(transform)[0];
5650
+ const scale = _util.Util.singularValueDecompose2dScale(transform)[0];
5283
5651
 
5284
- ctx.strokeStyle = strokeColor.getPattern(ctx, this);
5285
- ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth * scale);
5286
- ctx.stroke();
5287
- ctx.restore();
5288
- } else {
5289
- ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
5290
- ctx.stroke();
5652
+ ctx.strokeStyle = strokeColor.getPattern(ctx, this);
5653
+ ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth * scale);
5654
+ ctx.stroke();
5655
+ ctx.restore();
5656
+ } else {
5657
+ ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
5658
+ ctx.stroke();
5659
+ }
5291
5660
  }
5292
5661
 
5293
5662
  if (consumePath) {
@@ -5318,11 +5687,13 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
5318
5687
  needRestore = true;
5319
5688
  }
5320
5689
 
5321
- if (this.pendingEOFill) {
5322
- ctx.fill("evenodd");
5323
- this.pendingEOFill = false;
5324
- } else {
5325
- ctx.fill();
5690
+ if (this.contentVisible) {
5691
+ if (this.pendingEOFill) {
5692
+ ctx.fill("evenodd");
5693
+ this.pendingEOFill = false;
5694
+ } else {
5695
+ ctx.fill();
5696
+ }
5326
5697
  }
5327
5698
 
5328
5699
  if (needRestore) {
@@ -5667,15 +6038,15 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
5667
6038
  }
5668
6039
  }
5669
6040
 
5670
- if (glyph.isInFont || font.missingFile) {
6041
+ if (this.contentVisible && (glyph.isInFont || font.missingFile)) {
5671
6042
  if (simpleFillText && !accent) {
5672
6043
  ctx.fillText(character, scaledX, scaledY);
5673
6044
  } else {
5674
6045
  this.paintChar(character, scaledX, scaledY, patternTransform);
5675
6046
 
5676
6047
  if (accent) {
5677
- scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
5678
- scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
6048
+ scaledAccentX = scaledX + fontSize * accent.offset.x / fontSizeScale;
6049
+ scaledAccentY = scaledY - fontSize * accent.offset.y / fontSizeScale;
5679
6050
  this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform);
5680
6051
  }
5681
6052
  }
@@ -5747,12 +6118,14 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
5747
6118
  continue;
5748
6119
  }
5749
6120
 
5750
- this.processingType3 = glyph;
5751
- this.save();
5752
- ctx.scale(fontSize, fontSize);
5753
- ctx.transform.apply(ctx, fontMatrix);
5754
- this.executeOperatorList(operatorList);
5755
- this.restore();
6121
+ if (this.contentVisible) {
6122
+ this.processingType3 = glyph;
6123
+ this.save();
6124
+ ctx.scale(fontSize, fontSize);
6125
+ ctx.transform.apply(ctx, fontMatrix);
6126
+ this.executeOperatorList(operatorList);
6127
+ this.restore();
6128
+ }
5756
6129
 
5757
6130
  var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
5758
6131
 
@@ -5809,6 +6182,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
5809
6182
  this.current.patternFill = false;
5810
6183
  },
5811
6184
  shadingFill: function CanvasGraphics_shadingFill(patternIR) {
6185
+ if (!this.contentVisible) {
6186
+ return;
6187
+ }
6188
+
5812
6189
  var ctx = this.ctx;
5813
6190
  this.save();
5814
6191
  var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
@@ -5846,6 +6223,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
5846
6223
  (0, _util.unreachable)("Should not call beginImageData");
5847
6224
  },
5848
6225
  paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
6226
+ if (!this.contentVisible) {
6227
+ return;
6228
+ }
6229
+
5849
6230
  this.save();
5850
6231
  this.baseTransformStack.push(this.baseTransform);
5851
6232
 
@@ -5864,10 +6245,18 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
5864
6245
  }
5865
6246
  },
5866
6247
  paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
6248
+ if (!this.contentVisible) {
6249
+ return;
6250
+ }
6251
+
5867
6252
  this.restore();
5868
6253
  this.baseTransform = this.baseTransformStack.pop();
5869
6254
  },
5870
6255
  beginGroup: function CanvasGraphics_beginGroup(group) {
6256
+ if (!this.contentVisible) {
6257
+ return;
6258
+ }
6259
+
5871
6260
  this.save();
5872
6261
  var currentCtx = this.ctx;
5873
6262
 
@@ -5949,6 +6338,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
5949
6338
  this.current.activeSMask = null;
5950
6339
  },
5951
6340
  endGroup: function CanvasGraphics_endGroup(group) {
6341
+ if (!this.contentVisible) {
6342
+ return;
6343
+ }
6344
+
5952
6345
  this.groupLevel--;
5953
6346
  var groupCtx = this.ctx;
5954
6347
  this.ctx = this.groupStack.pop();
@@ -5997,6 +6390,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
5997
6390
  this.restore();
5998
6391
  },
5999
6392
  paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
6393
+ if (!this.contentVisible) {
6394
+ return;
6395
+ }
6396
+
6000
6397
  var ctx = this.ctx;
6001
6398
  var width = img.width,
6002
6399
  height = img.height;
@@ -6031,7 +6428,12 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
6031
6428
  maskCtx.restore();
6032
6429
  this.paintInlineImageXObject(maskCanvas.canvas);
6033
6430
  },
6034
- paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
6431
+
6432
+ paintImageMaskXObjectRepeat(imgData, scaleX, skewX = 0, skewY = 0, scaleY, positions) {
6433
+ if (!this.contentVisible) {
6434
+ return;
6435
+ }
6436
+
6035
6437
  var width = imgData.width;
6036
6438
  var height = imgData.height;
6037
6439
  var fillColor = this.current.fillColor;
@@ -6048,13 +6450,18 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
6048
6450
 
6049
6451
  for (var i = 0, ii = positions.length; i < ii; i += 2) {
6050
6452
  ctx.save();
6051
- ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
6453
+ ctx.transform(scaleX, skewX, skewY, scaleY, positions[i], positions[i + 1]);
6052
6454
  ctx.scale(1, -1);
6053
6455
  ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
6054
6456
  ctx.restore();
6055
6457
  }
6056
6458
  },
6459
+
6057
6460
  paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
6461
+ if (!this.contentVisible) {
6462
+ return;
6463
+ }
6464
+
6058
6465
  var ctx = this.ctx;
6059
6466
  var fillColor = this.current.fillColor;
6060
6467
  var isPatternFill = this.current.patternFill;
@@ -6079,6 +6486,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
6079
6486
  }
6080
6487
  },
6081
6488
  paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
6489
+ if (!this.contentVisible) {
6490
+ return;
6491
+ }
6492
+
6082
6493
  const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
6083
6494
 
6084
6495
  if (!imgData) {
@@ -6089,6 +6500,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
6089
6500
  this.paintInlineImageXObject(imgData);
6090
6501
  },
6091
6502
  paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
6503
+ if (!this.contentVisible) {
6504
+ return;
6505
+ }
6506
+
6092
6507
  const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
6093
6508
 
6094
6509
  if (!imgData) {
@@ -6113,6 +6528,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
6113
6528
  this.paintInlineImageXObjectGroup(imgData, map);
6114
6529
  },
6115
6530
  paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
6531
+ if (!this.contentVisible) {
6532
+ return;
6533
+ }
6534
+
6116
6535
  var width = imgData.width;
6117
6536
  var height = imgData.height;
6118
6537
  var ctx = this.ctx;
@@ -6132,7 +6551,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
6132
6551
  } else {
6133
6552
  tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
6134
6553
  var tmpCtx = tmpCanvas.context;
6135
- putBinaryImageData(tmpCtx, imgData);
6554
+ putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
6136
6555
  imgToPaint = tmpCanvas.canvas;
6137
6556
  }
6138
6557
 
@@ -6180,12 +6599,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
6180
6599
  this.restore();
6181
6600
  },
6182
6601
  paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
6602
+ if (!this.contentVisible) {
6603
+ return;
6604
+ }
6605
+
6183
6606
  var ctx = this.ctx;
6184
6607
  var w = imgData.width;
6185
6608
  var h = imgData.height;
6186
6609
  var tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
6187
6610
  var tmpCtx = tmpCanvas.context;
6188
- putBinaryImageData(tmpCtx, imgData);
6611
+ putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
6189
6612
 
6190
6613
  for (var i = 0, ii = map.length; i < ii; i++) {
6191
6614
  var entry = map[i];
@@ -6209,16 +6632,36 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
6209
6632
  }
6210
6633
  },
6211
6634
  paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
6635
+ if (!this.contentVisible) {
6636
+ return;
6637
+ }
6638
+
6212
6639
  this.ctx.fillRect(0, 0, 1, 1);
6213
6640
  },
6214
- paintXObject: function CanvasGraphics_paintXObject() {
6215
- (0, _util.warn)("Unsupported 'paintXObject' command.");
6216
- },
6217
6641
  markPoint: function CanvasGraphics_markPoint(tag) {},
6218
6642
  markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
6219
- beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {},
6220
- beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {},
6221
- endMarkedContent: function CanvasGraphics_endMarkedContent() {},
6643
+ beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
6644
+ this.markedContentStack.push({
6645
+ visible: true
6646
+ });
6647
+ },
6648
+ beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
6649
+ if (tag === "OC") {
6650
+ this.markedContentStack.push({
6651
+ visible: this.optionalContentConfig.isVisible(properties)
6652
+ });
6653
+ } else {
6654
+ this.markedContentStack.push({
6655
+ visible: true
6656
+ });
6657
+ }
6658
+
6659
+ this.contentVisible = this.isContentVisible();
6660
+ },
6661
+ endMarkedContent: function CanvasGraphics_endMarkedContent() {
6662
+ this.markedContentStack.pop();
6663
+ this.contentVisible = this.isContentVisible();
6664
+ },
6222
6665
  beginCompat: function CanvasGraphics_beginCompat() {},
6223
6666
  endCompat: function CanvasGraphics_endCompat() {},
6224
6667
  consumePath: function CanvasGraphics_consumePath() {
@@ -6249,6 +6692,15 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
6249
6692
  getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
6250
6693
  var transform = this.ctx.mozCurrentTransform;
6251
6694
  return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
6695
+ },
6696
+ isContentVisible: function CanvasGraphics_isContentVisible() {
6697
+ for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
6698
+ if (!this.markedContentStack[i].visible) {
6699
+ return false;
6700
+ }
6701
+ }
6702
+
6703
+ return true;
6252
6704
  }
6253
6705
  };
6254
6706
 
@@ -6262,7 +6714,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
6262
6714
  exports.CanvasGraphics = CanvasGraphics;
6263
6715
 
6264
6716
  /***/ }),
6265
- /* 9 */
6717
+ /* 11 */
6266
6718
  /***/ (function(module, exports, __w_pdfjs_require__) {
6267
6719
 
6268
6720
  "use strict";
@@ -6743,7 +7195,7 @@ var TilingPattern = function TilingPatternClosure() {
6743
7195
  exports.TilingPattern = TilingPattern;
6744
7196
 
6745
7197
  /***/ }),
6746
- /* 10 */
7198
+ /* 12 */
6747
7199
  /***/ (function(module, exports, __w_pdfjs_require__) {
6748
7200
 
6749
7201
  "use strict";
@@ -6759,7 +7211,7 @@ GlobalWorkerOptions.workerPort = GlobalWorkerOptions.workerPort === undefined ?
6759
7211
  GlobalWorkerOptions.workerSrc = GlobalWorkerOptions.workerSrc === undefined ? "" : GlobalWorkerOptions.workerSrc;
6760
7212
 
6761
7213
  /***/ }),
6762
- /* 11 */
7214
+ /* 13 */
6763
7215
  /***/ (function(module, exports, __w_pdfjs_require__) {
6764
7216
 
6765
7217
  "use strict";
@@ -7260,7 +7712,7 @@ class MessageHandler {
7260
7712
  exports.MessageHandler = MessageHandler;
7261
7713
 
7262
7714
  /***/ }),
7263
- /* 12 */
7715
+ /* 14 */
7264
7716
  /***/ (function(module, exports, __w_pdfjs_require__) {
7265
7717
 
7266
7718
  "use strict";
@@ -7273,7 +7725,7 @@ exports.Metadata = void 0;
7273
7725
 
7274
7726
  var _util = __w_pdfjs_require__(2);
7275
7727
 
7276
- var _xml_parser = __w_pdfjs_require__(13);
7728
+ var _xml_parser = __w_pdfjs_require__(15);
7277
7729
 
7278
7730
  class Metadata {
7279
7731
  constructor(data) {
@@ -7370,13 +7822,7 @@ class Metadata {
7370
7822
  }
7371
7823
 
7372
7824
  getAll() {
7373
- const obj = Object.create(null);
7374
-
7375
- for (const [key, value] of this._metadataMap) {
7376
- obj[key] = value;
7377
- }
7378
-
7379
- return obj;
7825
+ return Object.fromEntries(this._metadataMap);
7380
7826
  }
7381
7827
 
7382
7828
  has(name) {
@@ -7388,7 +7834,7 @@ class Metadata {
7388
7834
  exports.Metadata = Metadata;
7389
7835
 
7390
7836
  /***/ }),
7391
- /* 13 */
7837
+ /* 15 */
7392
7838
  /***/ (function(module, exports, __w_pdfjs_require__) {
7393
7839
 
7394
7840
  "use strict";
@@ -7831,7 +8277,176 @@ class SimpleXMLParser extends XMLParserBase {
7831
8277
  exports.SimpleXMLParser = SimpleXMLParser;
7832
8278
 
7833
8279
  /***/ }),
7834
- /* 14 */
8280
+ /* 16 */
8281
+ /***/ (function(module, exports, __w_pdfjs_require__) {
8282
+
8283
+ "use strict";
8284
+
8285
+
8286
+ Object.defineProperty(exports, "__esModule", {
8287
+ value: true
8288
+ });
8289
+ exports.OptionalContentConfig = void 0;
8290
+
8291
+ var _util = __w_pdfjs_require__(2);
8292
+
8293
+ class OptionalContentGroup {
8294
+ constructor(name, intent) {
8295
+ this.visible = true;
8296
+ this.name = name;
8297
+ this.intent = intent;
8298
+ }
8299
+
8300
+ }
8301
+
8302
+ class OptionalContentConfig {
8303
+ constructor(data) {
8304
+ this.name = null;
8305
+ this.creator = null;
8306
+ this._order = null;
8307
+ this._groups = new Map();
8308
+
8309
+ if (data === null) {
8310
+ return;
8311
+ }
8312
+
8313
+ this.name = data.name;
8314
+ this.creator = data.creator;
8315
+ this._order = data.order;
8316
+
8317
+ for (const group of data.groups) {
8318
+ this._groups.set(group.id, new OptionalContentGroup(group.name, group.intent));
8319
+ }
8320
+
8321
+ if (data.baseState === "OFF") {
8322
+ for (const group of this._groups) {
8323
+ group.visible = false;
8324
+ }
8325
+ }
8326
+
8327
+ for (const on of data.on) {
8328
+ this._groups.get(on).visible = true;
8329
+ }
8330
+
8331
+ for (const off of data.off) {
8332
+ this._groups.get(off).visible = false;
8333
+ }
8334
+ }
8335
+
8336
+ isVisible(group) {
8337
+ if (group.type === "OCG") {
8338
+ if (!this._groups.has(group.id)) {
8339
+ (0, _util.warn)(`Optional content group not found: ${group.id}`);
8340
+ return true;
8341
+ }
8342
+
8343
+ return this._groups.get(group.id).visible;
8344
+ } else if (group.type === "OCMD") {
8345
+ if (group.expression) {
8346
+ (0, _util.warn)("Visibility expression not supported yet.");
8347
+ }
8348
+
8349
+ if (!group.policy || group.policy === "AnyOn") {
8350
+ for (const id of group.ids) {
8351
+ if (!this._groups.has(id)) {
8352
+ (0, _util.warn)(`Optional content group not found: ${id}`);
8353
+ return true;
8354
+ }
8355
+
8356
+ if (this._groups.get(id).visible) {
8357
+ return true;
8358
+ }
8359
+ }
8360
+
8361
+ return false;
8362
+ } else if (group.policy === "AllOn") {
8363
+ for (const id of group.ids) {
8364
+ if (!this._groups.has(id)) {
8365
+ (0, _util.warn)(`Optional content group not found: ${id}`);
8366
+ return true;
8367
+ }
8368
+
8369
+ if (!this._groups.get(id).visible) {
8370
+ return false;
8371
+ }
8372
+ }
8373
+
8374
+ return true;
8375
+ } else if (group.policy === "AnyOff") {
8376
+ for (const id of group.ids) {
8377
+ if (!this._groups.has(id)) {
8378
+ (0, _util.warn)(`Optional content group not found: ${id}`);
8379
+ return true;
8380
+ }
8381
+
8382
+ if (!this._groups.get(id).visible) {
8383
+ return true;
8384
+ }
8385
+ }
8386
+
8387
+ return false;
8388
+ } else if (group.policy === "AllOff") {
8389
+ for (const id of group.ids) {
8390
+ if (!this._groups.has(id)) {
8391
+ (0, _util.warn)(`Optional content group not found: ${id}`);
8392
+ return true;
8393
+ }
8394
+
8395
+ if (this._groups.get(id).visible) {
8396
+ return false;
8397
+ }
8398
+ }
8399
+
8400
+ return true;
8401
+ }
8402
+
8403
+ (0, _util.warn)(`Unknown optional content policy ${group.policy}.`);
8404
+ return true;
8405
+ }
8406
+
8407
+ (0, _util.warn)(`Unknown group type ${group.type}.`);
8408
+ return true;
8409
+ }
8410
+
8411
+ setVisibility(id, visible = true) {
8412
+ if (!this._groups.has(id)) {
8413
+ (0, _util.warn)(`Optional content group not found: ${id}`);
8414
+ return;
8415
+ }
8416
+
8417
+ this._groups.get(id).visible = !!visible;
8418
+ }
8419
+
8420
+ getOrder() {
8421
+ if (!this._groups.size) {
8422
+ return null;
8423
+ }
8424
+
8425
+ if (this._order) {
8426
+ return this._order.slice();
8427
+ }
8428
+
8429
+ return Array.from(this._groups.keys());
8430
+ }
8431
+
8432
+ getGroups() {
8433
+ if (!this._groups.size) {
8434
+ return null;
8435
+ }
8436
+
8437
+ return Object.fromEntries(this._groups);
8438
+ }
8439
+
8440
+ getGroup(id) {
8441
+ return this._groups.get(id) || null;
8442
+ }
8443
+
8444
+ }
8445
+
8446
+ exports.OptionalContentConfig = OptionalContentConfig;
8447
+
8448
+ /***/ }),
8449
+ /* 17 */
7835
8450
  /***/ (function(module, exports, __w_pdfjs_require__) {
7836
8451
 
7837
8452
  "use strict";
@@ -8186,7 +8801,7 @@ class PDFDataTransportStreamRangeReader {
8186
8801
  }
8187
8802
 
8188
8803
  /***/ }),
8189
- /* 15 */
8804
+ /* 18 */
8190
8805
  /***/ (function(module, exports, __w_pdfjs_require__) {
8191
8806
 
8192
8807
  "use strict";
@@ -8633,7 +9248,7 @@ var WebGLUtils = function WebGLUtilsClosure() {
8633
9248
  }();
8634
9249
 
8635
9250
  /***/ }),
8636
- /* 16 */
9251
+ /* 19 */
8637
9252
  /***/ (function(module, exports, __w_pdfjs_require__) {
8638
9253
 
8639
9254
  "use strict";
@@ -8648,6 +9263,8 @@ var _display_utils = __w_pdfjs_require__(1);
8648
9263
 
8649
9264
  var _util = __w_pdfjs_require__(2);
8650
9265
 
9266
+ var _annotation_storage = __w_pdfjs_require__(8);
9267
+
8651
9268
  class AnnotationElementFactory {
8652
9269
  static create(parameters) {
8653
9270
  const subtype = parameters.data.annotationType;
@@ -8745,6 +9362,7 @@ class AnnotationElement {
8745
9362
  this.imageResourcesPath = parameters.imageResourcesPath;
8746
9363
  this.renderInteractiveForms = parameters.renderInteractiveForms;
8747
9364
  this.svgFactory = parameters.svgFactory;
9365
+ this.annotationStorage = parameters.annotationStorage;
8748
9366
 
8749
9367
  if (isRenderable) {
8750
9368
  this.container = this._createContainer(ignoreBorder);
@@ -8951,19 +9569,26 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
8951
9569
 
8952
9570
  render() {
8953
9571
  const TEXT_ALIGNMENT = ["left", "center", "right"];
9572
+ const storage = this.annotationStorage;
9573
+ const id = this.data.id;
8954
9574
  this.container.className = "textWidgetAnnotation";
8955
9575
  let element = null;
8956
9576
 
8957
9577
  if (this.renderInteractiveForms) {
9578
+ const textContent = storage.getOrCreateValue(id, this.data.fieldValue);
9579
+
8958
9580
  if (this.data.multiLine) {
8959
9581
  element = document.createElement("textarea");
8960
- element.textContent = this.data.fieldValue;
9582
+ element.textContent = textContent;
8961
9583
  } else {
8962
9584
  element = document.createElement("input");
8963
9585
  element.type = "text";
8964
- element.setAttribute("value", this.data.fieldValue);
9586
+ element.setAttribute("value", textContent);
8965
9587
  }
8966
9588
 
9589
+ element.addEventListener("input", function (event) {
9590
+ storage.setValue(id, event.target.value);
9591
+ });
8967
9592
  element.disabled = this.data.readOnly;
8968
9593
  element.name = this.data.fieldName;
8969
9594
 
@@ -9031,16 +9656,23 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
9031
9656
  }
9032
9657
 
9033
9658
  render() {
9659
+ const storage = this.annotationStorage;
9660
+ const data = this.data;
9661
+ const id = data.id;
9662
+ const value = storage.getOrCreateValue(id, data.fieldValue && data.fieldValue !== "Off");
9034
9663
  this.container.className = "buttonWidgetAnnotation checkBox";
9035
9664
  const element = document.createElement("input");
9036
- element.disabled = this.data.readOnly;
9665
+ element.disabled = data.readOnly;
9037
9666
  element.type = "checkbox";
9038
9667
  element.name = this.data.fieldName;
9039
9668
 
9040
- if (this.data.fieldValue && this.data.fieldValue !== "Off") {
9669
+ if (value) {
9041
9670
  element.setAttribute("checked", true);
9042
9671
  }
9043
9672
 
9673
+ element.addEventListener("change", function (event) {
9674
+ storage.setValue(id, event.target.checked);
9675
+ });
9044
9676
  this.container.appendChild(element);
9045
9677
  return this.container;
9046
9678
  }
@@ -9054,15 +9686,30 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
9054
9686
 
9055
9687
  render() {
9056
9688
  this.container.className = "buttonWidgetAnnotation radioButton";
9689
+ const storage = this.annotationStorage;
9690
+ const data = this.data;
9691
+ const id = data.id;
9692
+ const value = storage.getOrCreateValue(id, data.fieldValue === data.buttonValue);
9057
9693
  const element = document.createElement("input");
9058
- element.disabled = this.data.readOnly;
9694
+ element.disabled = data.readOnly;
9059
9695
  element.type = "radio";
9060
- element.name = this.data.fieldName;
9696
+ element.name = data.fieldName;
9061
9697
 
9062
- if (this.data.fieldValue === this.data.buttonValue) {
9698
+ if (value) {
9063
9699
  element.setAttribute("checked", true);
9064
9700
  }
9065
9701
 
9702
+ element.addEventListener("change", function (event) {
9703
+ const name = event.target.name;
9704
+
9705
+ for (const radio of document.getElementsByName(name)) {
9706
+ if (radio !== event.target) {
9707
+ storage.setValue(radio.parentNode.getAttribute("data-annotation-id"), false);
9708
+ }
9709
+ }
9710
+
9711
+ storage.setValue(id, event.target.checked);
9712
+ });
9066
9713
  this.container.appendChild(element);
9067
9714
  return this.container;
9068
9715
  }
@@ -9085,6 +9732,9 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
9085
9732
 
9086
9733
  render() {
9087
9734
  this.container.className = "choiceWidgetAnnotation";
9735
+ const storage = this.annotationStorage;
9736
+ const id = this.data.id;
9737
+ storage.getOrCreateValue(id, this.data.fieldValue.length > 0 ? this.data.fieldValue[0] : null);
9088
9738
  const selectElement = document.createElement("select");
9089
9739
  selectElement.disabled = this.data.readOnly;
9090
9740
  selectElement.name = this.data.fieldName;
@@ -9102,13 +9752,18 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
9102
9752
  optionElement.textContent = option.displayValue;
9103
9753
  optionElement.value = option.exportValue;
9104
9754
 
9105
- if (this.data.fieldValue.includes(option.displayValue)) {
9755
+ if (this.data.fieldValue.includes(option.exportValue)) {
9106
9756
  optionElement.setAttribute("selected", true);
9107
9757
  }
9108
9758
 
9109
9759
  selectElement.appendChild(optionElement);
9110
9760
  }
9111
9761
 
9762
+ selectElement.addEventListener("input", function (event) {
9763
+ const options = event.target.options;
9764
+ const value = options[options.selectedIndex].value;
9765
+ storage.setValue(id, value);
9766
+ });
9112
9767
  this.container.appendChild(selectElement);
9113
9768
  return this.container;
9114
9769
  }
@@ -9642,8 +10297,9 @@ class AnnotationLayer {
9642
10297
  linkService: parameters.linkService,
9643
10298
  downloadManager: parameters.downloadManager,
9644
10299
  imageResourcesPath: parameters.imageResourcesPath || "",
9645
- renderInteractiveForms: parameters.renderInteractiveForms || false,
9646
- svgFactory: new _display_utils.DOMSVGFactory()
10300
+ renderInteractiveForms: typeof parameters.renderInteractiveForms === "boolean" ? parameters.renderInteractiveForms : true,
10301
+ svgFactory: new _display_utils.DOMSVGFactory(),
10302
+ annotationStorage: parameters.annotationStorage || new _annotation_storage.AnnotationStorage()
9647
10303
  });
9648
10304
 
9649
10305
  if (element.isRenderable) {
@@ -9669,7 +10325,7 @@ class AnnotationLayer {
9669
10325
  exports.AnnotationLayer = AnnotationLayer;
9670
10326
 
9671
10327
  /***/ }),
9672
- /* 17 */
10328
+ /* 20 */
9673
10329
  /***/ (function(module, exports, __w_pdfjs_require__) {
9674
10330
 
9675
10331
  "use strict";
@@ -10116,6 +10772,7 @@ var renderTextLayer = function renderTextLayerClosure() {
10116
10772
  this._textContent = textContent;
10117
10773
  this._textContentStream = textContentStream;
10118
10774
  this._container = container;
10775
+ this._document = container.ownerDocument;
10119
10776
  this._viewport = viewport;
10120
10777
  this._textDivs = textDivs || [];
10121
10778
  this._textContentItemsStr = textContentItemsStr || [];
@@ -10222,7 +10879,9 @@ var renderTextLayer = function renderTextLayerClosure() {
10222
10879
  _render: function TextLayer_render(timeout) {
10223
10880
  const capability = (0, _util.createPromiseCapability)();
10224
10881
  let styleCache = Object.create(null);
10225
- const canvas = document.createElement("canvas");
10882
+
10883
+ const canvas = this._document.createElement("canvas");
10884
+
10226
10885
  canvas.mozOpaque = true;
10227
10886
  this._layoutTextCtx = canvas.getContext("2d", {
10228
10887
  alpha: false
@@ -10364,7 +11023,7 @@ var renderTextLayer = function renderTextLayerClosure() {
10364
11023
  exports.renderTextLayer = renderTextLayer;
10365
11024
 
10366
11025
  /***/ }),
10367
- /* 18 */
11026
+ /* 21 */
10368
11027
  /***/ (function(module, exports, __w_pdfjs_require__) {
10369
11028
 
10370
11029
  "use strict";
@@ -11769,7 +12428,7 @@ exports.SVGGraphics = SVGGraphics;
11769
12428
  }
11770
12429
 
11771
12430
  paintImageXObject(objId) {
11772
- const imgData = this.objs.get(objId);
12431
+ const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
11773
12432
 
11774
12433
  if (!imgData) {
11775
12434
  (0, _util.warn)(`Dependent image with object ID ${objId} is not ready yet`);
@@ -11890,7 +12549,7 @@ exports.SVGGraphics = SVGGraphics;
11890
12549
  }
11891
12550
 
11892
12551
  /***/ }),
11893
- /* 19 */
12552
+ /* 22 */
11894
12553
  /***/ (function(module, exports, __w_pdfjs_require__) {
11895
12554
 
11896
12555
  "use strict";
@@ -11903,7 +12562,7 @@ exports.PDFNodeStream = void 0;
11903
12562
 
11904
12563
  var _util = __w_pdfjs_require__(2);
11905
12564
 
11906
- var _network_utils = __w_pdfjs_require__(20);
12565
+ var _network_utils = __w_pdfjs_require__(23);
11907
12566
 
11908
12567
  ;
11909
12568
 
@@ -12359,7 +13018,7 @@ class PDFNodeStreamFsRangeReader extends BaseRangeReader {
12359
13018
  }
12360
13019
 
12361
13020
  /***/ }),
12362
- /* 20 */
13021
+ /* 23 */
12363
13022
  /***/ (function(module, exports, __w_pdfjs_require__) {
12364
13023
 
12365
13024
  "use strict";
@@ -12375,7 +13034,7 @@ exports.validateResponseStatus = validateResponseStatus;
12375
13034
 
12376
13035
  var _util = __w_pdfjs_require__(2);
12377
13036
 
12378
- var _content_disposition = __w_pdfjs_require__(21);
13037
+ var _content_disposition = __w_pdfjs_require__(24);
12379
13038
 
12380
13039
  function validateRangeRequestCapabilities({
12381
13040
  getResponseHeader,
@@ -12451,7 +13110,7 @@ function validateResponseStatus(status) {
12451
13110
  }
12452
13111
 
12453
13112
  /***/ }),
12454
- /* 21 */
13113
+ /* 24 */
12455
13114
  /***/ (function(module, exports, __w_pdfjs_require__) {
12456
13115
 
12457
13116
  "use strict";
@@ -12639,7 +13298,7 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
12639
13298
  }
12640
13299
 
12641
13300
  /***/ }),
12642
- /* 22 */
13301
+ /* 25 */
12643
13302
  /***/ (function(module, exports, __w_pdfjs_require__) {
12644
13303
 
12645
13304
  "use strict";
@@ -12652,7 +13311,7 @@ exports.PDFNetworkStream = void 0;
12652
13311
 
12653
13312
  var _util = __w_pdfjs_require__(2);
12654
13313
 
12655
- var _network_utils = __w_pdfjs_require__(20);
13314
+ var _network_utils = __w_pdfjs_require__(23);
12656
13315
 
12657
13316
  ;
12658
13317
  const OK_RESPONSE = 200;
@@ -12820,14 +13479,6 @@ class NetworkManager {
12820
13479
  }
12821
13480
  }
12822
13481
 
12823
- hasPendingRequests() {
12824
- for (const xhrId in this.pendingRequests) {
12825
- return true;
12826
- }
12827
-
12828
- return false;
12829
- }
12830
-
12831
13482
  getRequestXhr(xhrId) {
12832
13483
  return this.pendingRequests[xhrId].xhr;
12833
13484
  }
@@ -12836,12 +13487,6 @@ class NetworkManager {
12836
13487
  return xhrId in this.pendingRequests;
12837
13488
  }
12838
13489
 
12839
- abortAllRequests() {
12840
- for (const xhrId in this.pendingRequests) {
12841
- this.abortRequest(xhrId | 0);
12842
- }
12843
- }
12844
-
12845
13490
  abortRequest(xhrId) {
12846
13491
  const xhr = this.pendingRequests[xhrId].xhr;
12847
13492
  delete this.pendingRequests[xhrId];
@@ -13196,7 +13841,7 @@ class PDFNetworkStreamRangeRequestReader {
13196
13841
  }
13197
13842
 
13198
13843
  /***/ }),
13199
- /* 23 */
13844
+ /* 26 */
13200
13845
  /***/ (function(module, exports, __w_pdfjs_require__) {
13201
13846
 
13202
13847
  "use strict";
@@ -13209,7 +13854,7 @@ exports.PDFFetchStream = void 0;
13209
13854
 
13210
13855
  var _util = __w_pdfjs_require__(2);
13211
13856
 
13212
- var _network_utils = __w_pdfjs_require__(20);
13857
+ var _network_utils = __w_pdfjs_require__(23);
13213
13858
 
13214
13859
  ;
13215
13860
 
@@ -13434,6 +14079,12 @@ class PDFFetchStreamRangeReader {
13434
14079
  this._readCapability.resolve();
13435
14080
 
13436
14081
  this._reader = response.body.getReader();
14082
+ }).catch(reason => {
14083
+ if (reason && reason.name === "AbortError") {
14084
+ return;
14085
+ }
14086
+
14087
+ throw reason;
13437
14088
  });
13438
14089
  this.onProgress = null;
13439
14090
  }