@chialab/pdfjs-lib 1.0.0-alpha.15 → 1.0.0-alpha.16

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.
@@ -11,6 +11,7 @@ import {
11
11
  AnnotationType,
12
12
  BASELINE_FACTOR,
13
13
  BaseException,
14
+ DateFormats,
14
15
  DocumentActionEventType,
15
16
  DrawOPS,
16
17
  FONT_IDENTITY_MATRIX,
@@ -30,6 +31,7 @@ import {
30
31
  PermissionFlag,
31
32
  RenderingIntentFlag,
32
33
  TextRenderingMode,
34
+ TimeFormats,
33
35
  Util,
34
36
  VerbosityLevel,
35
37
  _isValidExplicitDest,
@@ -59,7 +61,7 @@ import {
59
61
  utf8StringToString,
60
62
  warn,
61
63
  wrapReason
62
- } from "./chunk-TKDBOXH4.js";
64
+ } from "./chunk-O4CM6PII.js";
63
65
  import {
64
66
  __privateAdd,
65
67
  __privateGet,
@@ -22572,7 +22574,7 @@ var CFFCompiler = class _CFFCompiler {
22572
22574
  // format
22573
22575
  0,
22574
22576
  // first CID upper byte
22575
- 0,
22577
+ 1,
22576
22578
  // first CID lower byte
22577
22579
  nLeft >> 8 & 255,
22578
22580
  nLeft & 255
@@ -55983,7 +55985,8 @@ var PartialEvaluator = class _PartialEvaluator {
55983
55985
  markedContentData = null,
55984
55986
  disableNormalization = false,
55985
55987
  keepWhiteSpace = false,
55986
- prevRefs = null
55988
+ prevRefs = null,
55989
+ intersector = null
55987
55990
  }) {
55988
55991
  const objId = stream.dict?.objId;
55989
55992
  const seenRefs = new RefSet(prevRefs);
@@ -56060,6 +56063,7 @@ var PartialEvaluator = class _PartialEvaluator {
56060
56063
  transform = textContentItem.prevTransform,
56061
56064
  fontName = textContentItem.fontName
56062
56065
  }) {
56066
+ intersector?.addExtraChar(" ");
56063
56067
  textContent.items.push({
56064
56068
  str: " ",
56065
56069
  dir: "ltr",
@@ -56397,9 +56401,21 @@ var PartialEvaluator = class _PartialEvaluator {
56397
56401
  }
56398
56402
  if (!font.vertical) {
56399
56403
  scaledDim *= textState.textHScale;
56404
+ intersector?.addGlyph(
56405
+ getCurrentTextTransform(),
56406
+ scaledDim,
56407
+ 0,
56408
+ glyph.unicode
56409
+ );
56400
56410
  textState.translateTextMatrix(scaledDim, 0);
56401
56411
  textChunk.width += scaledDim;
56402
56412
  } else {
56413
+ intersector?.addGlyph(
56414
+ getCurrentTextTransform(),
56415
+ 0,
56416
+ scaledDim,
56417
+ glyph.unicode
56418
+ );
56403
56419
  textState.translateTextMatrix(0, scaledDim);
56404
56420
  scaledDim = Math.abs(scaledDim);
56405
56421
  textChunk.height += scaledDim;
@@ -56410,8 +56426,11 @@ var PartialEvaluator = class _PartialEvaluator {
56410
56426
  const glyphUnicode = glyph.unicode;
56411
56427
  if (saveLastChar(glyphUnicode)) {
56412
56428
  textChunk.str.push(" ");
56429
+ intersector?.addExtraChar(" ");
56430
+ }
56431
+ if (!intersector) {
56432
+ textChunk.str.push(glyphUnicode);
56413
56433
  }
56414
- textChunk.str.push(glyphUnicode);
56415
56434
  if (charSpacing) {
56416
56435
  if (!font.vertical) {
56417
56436
  textState.translateTextMatrix(
@@ -56425,6 +56444,7 @@ var PartialEvaluator = class _PartialEvaluator {
56425
56444
  }
56426
56445
  }
56427
56446
  function appendEOL() {
56447
+ intersector?.addExtraChar("\n");
56428
56448
  resetLastChars();
56429
56449
  if (textContentItem.initialized) {
56430
56450
  textContentItem.hasEOL = true;
@@ -56446,6 +56466,7 @@ var PartialEvaluator = class _PartialEvaluator {
56446
56466
  if (textContentItem.initialized) {
56447
56467
  resetLastChars();
56448
56468
  textContentItem.str.push(" ");
56469
+ intersector?.addExtraChar(" ");
56449
56470
  }
56450
56471
  return false;
56451
56472
  }
@@ -56486,7 +56507,7 @@ var PartialEvaluator = class _PartialEvaluator {
56486
56507
  if (batch && length < TEXT_CHUNK_BATCH_SIZE) {
56487
56508
  return;
56488
56509
  }
56489
- sink.enqueue(textContent, length);
56510
+ sink?.enqueue(textContent, length);
56490
56511
  textContent.items = [];
56491
56512
  textContent.styles = /* @__PURE__ */ Object.create(null);
56492
56513
  }
@@ -56497,7 +56518,7 @@ var PartialEvaluator = class _PartialEvaluator {
56497
56518
  /* batch = */
56498
56519
  true
56499
56520
  );
56500
- Promise.all([promise, sink.ready]).then(function() {
56521
+ Promise.all([promise, sink?.ready]).then(function() {
56501
56522
  try {
56502
56523
  promiseBody(resolve, reject);
56503
56524
  } catch (ex) {
@@ -56700,7 +56721,7 @@ var PartialEvaluator = class _PartialEvaluator {
56700
56721
  sink.enqueue(chunk, size);
56701
56722
  },
56702
56723
  get desiredSize() {
56703
- return sink.desiredSize;
56724
+ return sink.desiredSize ?? 0;
56704
56725
  },
56705
56726
  get ready() {
56706
56727
  return sink.ready;
@@ -56712,7 +56733,7 @@ var PartialEvaluator = class _PartialEvaluator {
56712
56733
  resources: localResources instanceof Dict ? localResources : resources,
56713
56734
  stateManager: xObjStateManager,
56714
56735
  includeMarkedContent,
56715
- sink: sinkWrapper,
56736
+ sink: sink && sinkWrapper,
56716
56737
  seenStyles,
56717
56738
  viewBox,
56718
56739
  lang,
@@ -56825,7 +56846,7 @@ var PartialEvaluator = class _PartialEvaluator {
56825
56846
  }
56826
56847
  break;
56827
56848
  }
56828
- if (textContent.items.length >= sink.desiredSize) {
56849
+ if (textContent.items.length >= (sink?.desiredSize ?? 1)) {
56829
56850
  stop = true;
56830
56851
  break;
56831
56852
  }
@@ -74944,6 +74965,9 @@ var Annotation = class {
74944
74965
  async save(evaluator, task, annotationStorage, changes) {
74945
74966
  return null;
74946
74967
  }
74968
+ get overlaysTextContent() {
74969
+ return false;
74970
+ }
74947
74971
  get hasTextContent() {
74948
74972
  return false;
74949
74973
  }
@@ -76085,6 +76109,21 @@ var TextWidgetAnnotation = class extends WidgetAnnotation {
76085
76109
  this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
76086
76110
  this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.data.multiLine && !this.data.password && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== 0;
76087
76111
  this.data.doNotScroll = this.hasFieldFlag(AnnotationFieldFlag.DONOTSCROLL);
76112
+ const {
76113
+ data: { actions }
76114
+ } = this;
76115
+ for (const keystrokeAction of actions?.Keystroke || []) {
76116
+ const m = keystrokeAction.trim().match(/^AF(Date|Time)_Keystroke(?:Ex)?\(['"]?([^'"]+)['"]?\);$/);
76117
+ if (m) {
76118
+ let format = m[2];
76119
+ const num = parseInt(format, 10);
76120
+ if (!isNaN(num) && Math.floor(Math.log10(num)) + 1 === m[2].length) {
76121
+ format = (m[1] === "Date" ? DateFormats : TimeFormats)[num] ?? format;
76122
+ }
76123
+ this.data[m[1] === "Date" ? "dateFormat" : "timeFormat"] = format;
76124
+ break;
76125
+ }
76126
+ }
76088
76127
  }
76089
76128
  get hasTextContent() {
76090
76129
  return !!this.appearance && !this._needAppearances;
@@ -77575,6 +77614,9 @@ var HighlightAnnotation = class extends MarkupAnnotation {
77575
77614
  this.data.popupRef = null;
77576
77615
  }
77577
77616
  }
77617
+ get overlaysTextContent() {
77618
+ return true;
77619
+ }
77578
77620
  static createNewDict(annotation, xref, { apRef, ap }) {
77579
77621
  const { color, oldAnnotation, opacity, rect, rotation, user, quadPoints } = annotation;
77580
77622
  const highlight = oldAnnotation || new Dict(xref);
@@ -77679,6 +77721,9 @@ var UnderlineAnnotation = class extends MarkupAnnotation {
77679
77721
  this.data.popupRef = null;
77680
77722
  }
77681
77723
  }
77724
+ get overlaysTextContent() {
77725
+ return true;
77726
+ }
77682
77727
  };
77683
77728
  var SquigglyAnnotation = class extends MarkupAnnotation {
77684
77729
  constructor(params) {
@@ -77716,6 +77761,9 @@ var SquigglyAnnotation = class extends MarkupAnnotation {
77716
77761
  this.data.popupRef = null;
77717
77762
  }
77718
77763
  }
77764
+ get overlaysTextContent() {
77765
+ return true;
77766
+ }
77719
77767
  };
77720
77768
  var StrikeOutAnnotation = class extends MarkupAnnotation {
77721
77769
  constructor(params) {
@@ -77746,6 +77794,9 @@ var StrikeOutAnnotation = class extends MarkupAnnotation {
77746
77794
  this.data.popupRef = null;
77747
77795
  }
77748
77796
  }
77797
+ get overlaysTextContent() {
77798
+ return true;
77799
+ }
77749
77800
  };
77750
77801
  var _savedHasOwnCanvas, _StampAnnotation_static, createNewAppearanceStreamForDrawing_fn;
77751
77802
  var StampAnnotation = class extends MarkupAnnotation {
@@ -78786,6 +78837,156 @@ var DatasetReader = class {
78786
78837
  }
78787
78838
  };
78788
78839
 
78840
+ // src/pdf.js/src/core/intersector.js
78841
+ var _annotation, _minX, _minY, _maxX, _maxY, _quadPoints, _text, _extraChars, _lastIntersectingQuadIndex, _canTakeExtraChars, _SingleIntersector_instances, intersects_fn;
78842
+ var SingleIntersector = class {
78843
+ constructor(annotation) {
78844
+ __privateAdd(this, _SingleIntersector_instances);
78845
+ __privateAdd(this, _annotation);
78846
+ __privateAdd(this, _minX, Infinity);
78847
+ __privateAdd(this, _minY, Infinity);
78848
+ __privateAdd(this, _maxX, -Infinity);
78849
+ __privateAdd(this, _maxY, -Infinity);
78850
+ __privateAdd(this, _quadPoints);
78851
+ __privateAdd(this, _text, []);
78852
+ __privateAdd(this, _extraChars, []);
78853
+ __privateAdd(this, _lastIntersectingQuadIndex, -1);
78854
+ __privateAdd(this, _canTakeExtraChars, false);
78855
+ __privateSet(this, _annotation, annotation);
78856
+ const quadPoints = __privateSet(this, _quadPoints, annotation.data.quadPoints);
78857
+ for (let i = 0, ii = quadPoints.length; i < ii; i += 8) {
78858
+ __privateSet(this, _minX, Math.min(__privateGet(this, _minX), quadPoints[i]));
78859
+ __privateSet(this, _maxX, Math.max(__privateGet(this, _maxX), quadPoints[i + 2]));
78860
+ __privateSet(this, _minY, Math.min(__privateGet(this, _minY), quadPoints[i + 5]));
78861
+ __privateSet(this, _maxY, Math.max(__privateGet(this, _maxY), quadPoints[i + 1]));
78862
+ }
78863
+ }
78864
+ overlaps(other) {
78865
+ return !(__privateGet(this, _minX) >= __privateGet(other, _maxX) || __privateGet(this, _maxX) <= __privateGet(other, _minX) || __privateGet(this, _minY) >= __privateGet(other, _maxY) || __privateGet(this, _maxY) <= __privateGet(other, _minY));
78866
+ }
78867
+ addGlyph(x, y, glyph) {
78868
+ if (!__privateMethod(this, _SingleIntersector_instances, intersects_fn).call(this, x, y)) {
78869
+ this.disableExtraChars();
78870
+ return false;
78871
+ }
78872
+ if (__privateGet(this, _extraChars).length > 0) {
78873
+ __privateGet(this, _text).push(__privateGet(this, _extraChars).join(""));
78874
+ __privateGet(this, _extraChars).length = 0;
78875
+ }
78876
+ __privateGet(this, _text).push(glyph);
78877
+ __privateSet(this, _canTakeExtraChars, true);
78878
+ return true;
78879
+ }
78880
+ addExtraChar(char) {
78881
+ if (__privateGet(this, _canTakeExtraChars)) {
78882
+ __privateGet(this, _extraChars).push(char);
78883
+ }
78884
+ }
78885
+ disableExtraChars() {
78886
+ if (!__privateGet(this, _canTakeExtraChars)) {
78887
+ return;
78888
+ }
78889
+ __privateSet(this, _canTakeExtraChars, false);
78890
+ __privateGet(this, _extraChars).length = 0;
78891
+ }
78892
+ setText() {
78893
+ __privateGet(this, _annotation).data.overlaidText = __privateGet(this, _text).join("");
78894
+ }
78895
+ };
78896
+ _annotation = new WeakMap();
78897
+ _minX = new WeakMap();
78898
+ _minY = new WeakMap();
78899
+ _maxX = new WeakMap();
78900
+ _maxY = new WeakMap();
78901
+ _quadPoints = new WeakMap();
78902
+ _text = new WeakMap();
78903
+ _extraChars = new WeakMap();
78904
+ _lastIntersectingQuadIndex = new WeakMap();
78905
+ _canTakeExtraChars = new WeakMap();
78906
+ _SingleIntersector_instances = new WeakSet();
78907
+ /**
78908
+ * Check if the given point intersects with the annotation's quad points.
78909
+ * The point (x, y) is supposed to be the center of the glyph.
78910
+ * @param {number} x
78911
+ * @param {number} y
78912
+ * @returns {boolean}
78913
+ */
78914
+ intersects_fn = function(x, y) {
78915
+ if (__privateGet(this, _minX) >= x || __privateGet(this, _maxX) <= x || __privateGet(this, _minY) >= y || __privateGet(this, _maxY) <= y) {
78916
+ return false;
78917
+ }
78918
+ const quadPoints = __privateGet(this, _quadPoints);
78919
+ if (quadPoints.length === 8) {
78920
+ return true;
78921
+ }
78922
+ if (__privateGet(this, _lastIntersectingQuadIndex) >= 0) {
78923
+ const i = __privateGet(this, _lastIntersectingQuadIndex);
78924
+ if (!(quadPoints[i] >= x || quadPoints[i + 2] <= x || quadPoints[i + 5] >= y || quadPoints[i + 1] <= y)) {
78925
+ return true;
78926
+ }
78927
+ __privateSet(this, _lastIntersectingQuadIndex, -1);
78928
+ }
78929
+ for (let i = 0, ii = quadPoints.length; i < ii; i += 8) {
78930
+ if (!(quadPoints[i] >= x || quadPoints[i + 2] <= x || quadPoints[i + 5] >= y || quadPoints[i + 1] <= y)) {
78931
+ __privateSet(this, _lastIntersectingQuadIndex, i);
78932
+ return true;
78933
+ }
78934
+ }
78935
+ return false;
78936
+ };
78937
+ var _intersectors;
78938
+ var Intersector = class {
78939
+ constructor(annotations) {
78940
+ __privateAdd(this, _intersectors, /* @__PURE__ */ new Map());
78941
+ for (const annotation of annotations) {
78942
+ if (!annotation.data.quadPoints) {
78943
+ continue;
78944
+ }
78945
+ const intersector = new SingleIntersector(annotation);
78946
+ for (const [otherIntersector, overlapping] of __privateGet(this, _intersectors)) {
78947
+ if (otherIntersector.overlaps(intersector)) {
78948
+ if (!overlapping) {
78949
+ __privateGet(this, _intersectors).set(otherIntersector, /* @__PURE__ */ new Set([intersector]));
78950
+ } else {
78951
+ overlapping.add(intersector);
78952
+ }
78953
+ }
78954
+ }
78955
+ __privateGet(this, _intersectors).set(intersector, null);
78956
+ }
78957
+ }
78958
+ addGlyph(transform, width, height, glyph) {
78959
+ const x = transform[4] + width / 2;
78960
+ const y = transform[5] + height / 2;
78961
+ let overlappingIntersectors;
78962
+ for (const [intersector, overlapping] of __privateGet(this, _intersectors)) {
78963
+ if (overlappingIntersectors) {
78964
+ if (overlappingIntersectors.has(intersector)) {
78965
+ intersector.addGlyph(x, y, glyph);
78966
+ } else {
78967
+ intersector.disableExtraChars();
78968
+ }
78969
+ continue;
78970
+ }
78971
+ if (!intersector.addGlyph(x, y, glyph)) {
78972
+ continue;
78973
+ }
78974
+ overlappingIntersectors = overlapping;
78975
+ }
78976
+ }
78977
+ addExtraChar(char) {
78978
+ for (const intersector of __privateGet(this, _intersectors).keys()) {
78979
+ intersector.addExtraChar(char);
78980
+ }
78981
+ }
78982
+ setText() {
78983
+ for (const intersector of __privateGet(this, _intersectors).keys()) {
78984
+ intersector.setText();
78985
+ }
78986
+ }
78987
+ };
78988
+ _intersectors = new WeakMap();
78989
+
78789
78990
  // src/pdf.js/src/core/calculate_sha_other.js
78790
78991
  var Word64 = class {
78791
78992
  constructor(highInteger, lowInteger) {
@@ -82364,7 +82565,8 @@ var Page = class {
82364
82565
  task,
82365
82566
  includeMarkedContent,
82366
82567
  disableNormalization,
82367
- sink
82568
+ sink,
82569
+ intersector = null
82368
82570
  }) {
82369
82571
  const contentStreamPromise = this.getContentStream();
82370
82572
  const resourcesPromise = this.loadResources(RESOURCES_KEYS_TEXT_CONTENT);
@@ -82384,7 +82586,8 @@ var Page = class {
82384
82586
  disableNormalization,
82385
82587
  sink,
82386
82588
  viewBox: this.view,
82387
- lang
82589
+ lang,
82590
+ intersector
82388
82591
  });
82389
82592
  }
82390
82593
  async getStructTree() {
@@ -82422,6 +82625,7 @@ var Page = class {
82422
82625
  const annotationsData = [], textContentPromises = [];
82423
82626
  let partialEvaluator;
82424
82627
  const intentAny = !!(intent & RenderingIntentFlag.ANY), intentDisplay = !!(intent & RenderingIntentFlag.DISPLAY), intentPrint = !!(intent & RenderingIntentFlag.PRINT);
82628
+ const highlightedAnnotations = [];
82425
82629
  for (const annotation of annotations) {
82426
82630
  const isVisible = intentAny || intentDisplay && annotation.viewable;
82427
82631
  if (isVisible || intentPrint && annotation.printable) {
@@ -82441,8 +82645,27 @@ var Page = class {
82441
82645
  );
82442
82646
  })
82443
82647
  );
82648
+ } else if (annotation.overlaysTextContent && isVisible) {
82649
+ highlightedAnnotations.push(annotation);
82444
82650
  }
82445
82651
  }
82652
+ if (highlightedAnnotations.length > 0) {
82653
+ const intersector = new Intersector(highlightedAnnotations);
82654
+ textContentPromises.push(
82655
+ this.extractTextContent({
82656
+ handler,
82657
+ task,
82658
+ includeMarkedContent: false,
82659
+ disableNormalization: false,
82660
+ sink: null,
82661
+ viewBox: this.view,
82662
+ lang: null,
82663
+ intersector
82664
+ }).then(() => {
82665
+ intersector.setText();
82666
+ })
82667
+ );
82668
+ }
82446
82669
  await Promise.all(textContentPromises);
82447
82670
  return annotationsData;
82448
82671
  }
@@ -82679,7 +82902,7 @@ function find(stream, signature, limit = 1024, backwards = false) {
82679
82902
  }
82680
82903
  return false;
82681
82904
  }
82682
- var _pagePromises, _version, _PDFDocument_instances, hasOnlyDocumentSignatures_fn, loadXfaImages_fn, loadXfaFonts_fn, getLinearizationPage_fn, collectFieldObjects_fn;
82905
+ var _pagePromises, _version, _PDFDocument_instances, hasOnlyDocumentSignatures_fn, collectSignatureCertificates_fn, loadXfaImages_fn, loadXfaFonts_fn, getLinearizationPage_fn, collectFieldObjects_fn;
82683
82906
  var PDFDocument = class {
82684
82907
  constructor(pdfManager, stream) {
82685
82908
  __privateAdd(this, _PDFDocument_instances);
@@ -82952,6 +83175,17 @@ var PDFDocument = class {
82952
83175
  formInfo.hasXfa = Array.isArray(xfa) && xfa.length > 0 || xfa instanceof BaseStream && !xfa.isEmpty;
82953
83176
  const sigFlags = acroForm.get("SigFlags");
82954
83177
  const hasSignatures = !!(sigFlags & 1);
83178
+ if (false) {
83179
+ if (hasSignatures) {
83180
+ const collectedSignatureCertificates = /* @__PURE__ */ new Set();
83181
+ __privateMethod(this, _PDFDocument_instances, collectSignatureCertificates_fn).call(this, fields, collectedSignatureCertificates);
83182
+ if (collectedSignatureCertificates.size > 0) {
83183
+ formInfo.collectedSignatureCertificates = Array.from(
83184
+ collectedSignatureCertificates
83185
+ );
83186
+ }
83187
+ }
83188
+ }
82955
83189
  const hasOnlyDocumentSignatures = hasSignatures && __privateMethod(this, _PDFDocument_instances, hasOnlyDocumentSignatures_fn).call(this, fields);
82956
83190
  formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
82957
83191
  formInfo.hasSignatures = hasSignatures;
@@ -82975,6 +83209,9 @@ var PDFDocument = class {
82975
83209
  IsCollectionPresent: !!catalog.collection,
82976
83210
  IsSignaturesPresent: formInfo.hasSignatures
82977
83211
  };
83212
+ if (false) {
83213
+ docInfo.collectedSignatureCertificates = formInfo.collectedSignatureCertificates ?? null;
83214
+ }
82978
83215
  let infoDict;
82979
83216
  try {
82980
83217
  infoDict = xref.trailer.get("Info");
@@ -83298,6 +83535,40 @@ hasOnlyDocumentSignatures_fn = function(fields, recursionDepth = 0) {
83298
83535
  return isSignature && isInvisible;
83299
83536
  });
83300
83537
  };
83538
+ collectSignatureCertificates_fn = function(fields, collectedSignatureCertificates, visited = new RefSet()) {
83539
+ if (!Array.isArray(fields)) {
83540
+ return;
83541
+ }
83542
+ for (let field of fields) {
83543
+ if (field instanceof Ref) {
83544
+ if (visited.has(field)) {
83545
+ continue;
83546
+ }
83547
+ visited.put(field);
83548
+ }
83549
+ field = this.xref.fetchIfRef(field);
83550
+ if (!(field instanceof Dict)) {
83551
+ continue;
83552
+ }
83553
+ if (field.has("Kids")) {
83554
+ __privateMethod(this, _PDFDocument_instances, collectSignatureCertificates_fn).call(this, field.get("Kids"), collectedSignatureCertificates, visited);
83555
+ continue;
83556
+ }
83557
+ const isSignature = isName(field.get("FT"), "Sig");
83558
+ if (!isSignature) {
83559
+ continue;
83560
+ }
83561
+ const value = field.get("V");
83562
+ if (!(value instanceof Dict)) {
83563
+ continue;
83564
+ }
83565
+ const subFilter = value.get("SubFilter");
83566
+ if (!(subFilter instanceof Name)) {
83567
+ continue;
83568
+ }
83569
+ collectedSignatureCertificates.add(subFilter.name);
83570
+ }
83571
+ };
83301
83572
  loadXfaImages_fn = async function() {
83302
83573
  const xfaImages = await this.pdfManager.ensureCatalog("xfaImages");
83303
83574
  if (!xfaImages) {
@@ -1,7 +1,7 @@
1
1
  import { Path2D } from './Path2D';
2
2
  interface CanvasStyle {
3
- strokeStyle: string | SvgGradient | SvgPattern;
4
- fillStyle: string | SvgGradient | SvgPattern;
3
+ strokeStyle: string | SvgLinearGradient | SvgPattern;
4
+ fillStyle: string | SvgLinearGradient | SvgRadialGradient | SvgPattern;
5
5
  fillRule: CanvasFillRule;
6
6
  filter: string;
7
7
  lineCap: CanvasLineCap;
@@ -28,7 +28,7 @@ declare class SvgPattern {
28
28
  constructor(src: string, width: number, height: number);
29
29
  setTransform(matrix: DOMMatrix): void;
30
30
  }
31
- declare class SvgGradient {
31
+ declare class SvgLinearGradient {
32
32
  readonly x1: number;
33
33
  readonly y1: number;
34
34
  readonly x2: number;
@@ -40,6 +40,20 @@ declare class SvgGradient {
40
40
  constructor(x1: number, y1: number, x2: number, y2: number);
41
41
  addColorStop(offset: number, color: string): void;
42
42
  }
43
+ declare class SvgRadialGradient {
44
+ readonly x0: number;
45
+ readonly y0: number;
46
+ readonly r0: number;
47
+ readonly x1: number;
48
+ readonly y1: number;
49
+ readonly r1: number;
50
+ readonly stops: {
51
+ offset: number;
52
+ color: string;
53
+ }[];
54
+ constructor(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number);
55
+ addColorStop(offset: number, color: string): void;
56
+ }
43
57
  export interface SvgNode {
44
58
  tag: string;
45
59
  attrs: Record<string, string | undefined>;
@@ -125,7 +139,8 @@ export declare class SvgCanvasContext {
125
139
  setLineDash(dashArray: number[]): void;
126
140
  drawImage(image: CanvasImageSource, ...args: number[]): void;
127
141
  createPattern(image: CanvasImageSource, repetition: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat' | null): SvgPattern;
128
- createLinearGradient(x1: number, x2: number, y1: number, y2: number): SvgGradient;
142
+ createLinearGradient(x1: number, x2: number, y1: number, y2: number): SvgLinearGradient;
143
+ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): SvgRadialGradient;
129
144
  clip(path: Path2D, fillRule: CanvasFillRule): void;
130
145
  measureText(text: string): TextMetrics;
131
146
  resetTransform(): void;
@@ -146,7 +161,7 @@ export declare class SvgCanvasContext {
146
161
  };
147
162
  protected _applyTransformation(node: SvgNode, matrix?: DOMMatrix): void;
148
163
  protected _createPatternNode(pattern: SvgPattern, transform?: DOMMatrix): SvgElement;
149
- protected _createGradientNode(gradient: SvgGradient): SvgElement;
164
+ protected _createGradientNode(gradient: SvgLinearGradient | SvgRadialGradient): SvgElement;
150
165
  protected _applyStyle(currentElement: SvgNode, type: 'fill' | 'stroke'): void;
151
166
  protected _addPathCommand(command: string): void;
152
167
  protected _applyText(text: string, x: number, y: number, action: 'fill'): void;
@@ -1640,6 +1640,91 @@ deleteStreamController_fn = async function(streamController, streamId) {
1640
1640
  delete this.streamControllers[streamId];
1641
1641
  };
1642
1642
 
1643
+ // src/pdf.js/src/shared/scripting_utils.js
1644
+ function makeColorComp(n) {
1645
+ return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
1646
+ }
1647
+ function scaleAndClamp(x) {
1648
+ return Math.max(0, Math.min(255, 255 * x));
1649
+ }
1650
+ var ColorConverters = class {
1651
+ static CMYK_G([c, y, m, k]) {
1652
+ return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
1653
+ }
1654
+ static G_CMYK([g]) {
1655
+ return ["CMYK", 0, 0, 0, 1 - g];
1656
+ }
1657
+ static G_RGB([g]) {
1658
+ return ["RGB", g, g, g];
1659
+ }
1660
+ static G_rgb([g]) {
1661
+ g = scaleAndClamp(g);
1662
+ return [g, g, g];
1663
+ }
1664
+ static G_HTML([g]) {
1665
+ const G = makeColorComp(g);
1666
+ return `#${G}${G}${G}`;
1667
+ }
1668
+ static RGB_G([r, g, b]) {
1669
+ return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
1670
+ }
1671
+ static RGB_rgb(color) {
1672
+ return color.map(scaleAndClamp);
1673
+ }
1674
+ static RGB_HTML(color) {
1675
+ return `#${color.map(makeColorComp).join("")}`;
1676
+ }
1677
+ static T_HTML() {
1678
+ return "#00000000";
1679
+ }
1680
+ static T_rgb() {
1681
+ return [null];
1682
+ }
1683
+ static CMYK_RGB([c, y, m, k]) {
1684
+ return [
1685
+ "RGB",
1686
+ 1 - Math.min(1, c + k),
1687
+ 1 - Math.min(1, m + k),
1688
+ 1 - Math.min(1, y + k)
1689
+ ];
1690
+ }
1691
+ static CMYK_rgb([c, y, m, k]) {
1692
+ return [
1693
+ scaleAndClamp(1 - Math.min(1, c + k)),
1694
+ scaleAndClamp(1 - Math.min(1, m + k)),
1695
+ scaleAndClamp(1 - Math.min(1, y + k))
1696
+ ];
1697
+ }
1698
+ static CMYK_HTML(components) {
1699
+ const rgb = this.CMYK_RGB(components).slice(1);
1700
+ return this.RGB_HTML(rgb);
1701
+ }
1702
+ static RGB_CMYK([r, g, b]) {
1703
+ const c = 1 - r;
1704
+ const m = 1 - g;
1705
+ const y = 1 - b;
1706
+ const k = Math.min(c, m, y);
1707
+ return ["CMYK", c, m, y, k];
1708
+ }
1709
+ };
1710
+ var DateFormats = [
1711
+ "m/d",
1712
+ "m/d/yy",
1713
+ "mm/dd/yy",
1714
+ "mm/yy",
1715
+ "d-mmm",
1716
+ "d-mmm-yy",
1717
+ "dd-mmm-yy",
1718
+ "yy-mm-dd",
1719
+ "mmm-yy",
1720
+ "mmmm-yy",
1721
+ "mmm d, yyyy",
1722
+ "mmmm d, yyyy",
1723
+ "m/d/yy h:MM tt",
1724
+ "m/d/yy HH:MM"
1725
+ ];
1726
+ var TimeFormats = ["HH:MM", "h:MM tt", "HH:MM:ss", "h:MM:ss tt"];
1727
+
1643
1728
  // src/pdf.js/src/shared/murmurhash3.js
1644
1729
  var SEED = 3285377520;
1645
1730
  var MASK_HIGH = 4294901760;
@@ -1897,5 +1982,8 @@ export {
1897
1982
  MessageHandler,
1898
1983
  convertToRGBA,
1899
1984
  convertBlackAndWhiteToRGBA,
1900
- grayToRGBA
1985
+ grayToRGBA,
1986
+ ColorConverters,
1987
+ DateFormats,
1988
+ TimeFormats
1901
1989
  };