@syncfusion/ej2-pdf 23.1.39 → 23.2.4

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.
@@ -13561,6 +13561,7 @@ class PdfAnnotation {
13561
13561
  this._isImported = false;
13562
13562
  this._isLoaded = false;
13563
13563
  this._setAppearance = false;
13564
+ this._isExport = false;
13564
13565
  this._opacity = 1;
13565
13566
  this._isAllRotation = true;
13566
13567
  this._flatten = false;
@@ -21352,12 +21353,17 @@ class PdfDocumentLinkAnnotation extends PdfAnnotation {
21352
21353
  else if (this._dictionary.has('A') && !this._destination) {
21353
21354
  const action = this._dictionary.get('A');
21354
21355
  if (action.has('D')) {
21355
- const reference = action.get('D');
21356
- if (reference) {
21357
- const referenceValue = this._crossReference._fetch(reference); // eslint-disable-line
21356
+ const reference = action.get('D'); // eslint-disable-line
21357
+ if (reference !== null && typeof reference !== 'undefined') {
21358
21358
  let referenceArray; // eslint-disable-line
21359
- if (Array.isArray(referenceValue)) {
21360
- referenceArray = referenceValue;
21359
+ if (Array.isArray(reference)) {
21360
+ referenceArray = reference;
21361
+ }
21362
+ else if (reference instanceof _PdfReference) {
21363
+ const referenceValue = this._crossReference._fetch(reference); // eslint-disable-line
21364
+ if (Array.isArray(referenceValue)) {
21365
+ referenceArray = referenceValue;
21366
+ }
21361
21367
  }
21362
21368
  if (referenceArray) {
21363
21369
  if (referenceArray[0] instanceof _PdfReference) {
@@ -22841,11 +22847,11 @@ class PdfRubberStampAnnotation extends PdfComment {
22841
22847
  }
22842
22848
  _doPostProcess(isFlatten = false) {
22843
22849
  let isTransformBBox = false;
22844
- if (this._isLoaded && (this._setAppearance || isFlatten)) {
22845
- if (!isFlatten) {
22850
+ if (this._isLoaded && (this._setAppearance || isFlatten || this._isExport)) {
22851
+ if ((!isFlatten && !this._isExport) || this._setAppearance) {
22846
22852
  this._appearanceTemplate = this._createRubberStampAppearance();
22847
22853
  }
22848
- if (!this._appearanceTemplate && isFlatten && this._dictionary.has('AP')) {
22854
+ if (!this._appearanceTemplate && (this._isExport || isFlatten) && this._dictionary.has('AP')) {
22849
22855
  const dictionary = this._dictionary.get('AP');
22850
22856
  if (dictionary && dictionary.has('N')) {
22851
22857
  const appearanceStream = dictionary.get('N');
@@ -22902,8 +22908,10 @@ class PdfRubberStampAnnotation extends PdfComment {
22902
22908
  }
22903
22909
  }
22904
22910
  else {
22905
- this._postProcess();
22906
- if ((!this._appearanceTemplate) && isFlatten) {
22911
+ if (!(this._isImported && this._dictionary.has('AP'))) {
22912
+ this._postProcess();
22913
+ }
22914
+ if ((!this._appearanceTemplate) && (isFlatten || this._isImported)) {
22907
22915
  if (!this._dictionary.has('AP')) {
22908
22916
  this._appearanceTemplate = this._createRubberStampAppearance();
22909
22917
  }
@@ -27161,6 +27169,7 @@ class PdfAnnotationCollection {
27161
27169
  * @param {PdfPage} page PDF page object.
27162
27170
  */
27163
27171
  constructor(array, xref, page) {
27172
+ this._isExport = false;
27164
27173
  this._annotations = array;
27165
27174
  this._page = page;
27166
27175
  this._crossReference = xref;
@@ -27550,6 +27559,7 @@ class PdfAnnotationCollection {
27550
27559
  for (let i = this.count - 1; i >= 0; i--) {
27551
27560
  const annotation = this.at(i);
27552
27561
  if (annotation) {
27562
+ annotation._isExport = this._isExport;
27553
27563
  annotation._doPostProcess(annotation.flatten || isFlatten);
27554
27564
  }
27555
27565
  }
@@ -36044,16 +36054,20 @@ class _PdfCatalog {
36044
36054
  if (this._catalogDictionary.has('AcroForm')) {
36045
36055
  form = this._catalogDictionary.get('AcroForm');
36046
36056
  }
36047
- else {
36048
- form = new _PdfDictionary(this._crossReference);
36049
- const ref = this._crossReference._getNextReference();
36050
- this._crossReference._cacheMap.set(ref, form);
36051
- this._catalogDictionary.set('AcroForm', ref);
36052
- this._catalogDictionary._updated = true;
36057
+ if (form === null || typeof form === 'undefined') {
36058
+ form = this._createForm();
36053
36059
  }
36054
36060
  return form;
36055
36061
  }
36056
36062
  /* eslint-disable */
36063
+ _createForm() {
36064
+ const form = new _PdfDictionary(this._crossReference);
36065
+ const ref = this._crossReference._getNextReference();
36066
+ this._crossReference._cacheMap.set(ref, form);
36067
+ this._catalogDictionary.set('AcroForm', ref);
36068
+ this._catalogDictionary._updated = true;
36069
+ return form;
36070
+ }
36057
36071
  getPageDictionary(pageIndex) {
36058
36072
  const nodesToVisit = [this._topPagesDictionary];
36059
36073
  const visitedNodes = new _PdfReferenceSet();
@@ -37111,7 +37125,7 @@ class _PdfParser {
37111
37125
  const dictBytes = stream.getBytes(dictLength);
37112
37126
  stream.position = initialStreamPos;
37113
37127
  cacheKey = this._computeMaxNumber(imageBytes) + '_' + this._computeMaxNumber(dictBytes);
37114
- const cacheEntry = this.imageCache[cacheKey]; // eslint-disable-line
37128
+ const cacheEntry = this.imageCache.get(cacheKey);
37115
37129
  if (cacheEntry !== undefined) {
37116
37130
  this.second = _PdfCommand.get('EI');
37117
37131
  this.shift();
@@ -37125,7 +37139,7 @@ class _PdfParser {
37125
37139
  imageStream = this.filter(imageStream, dictionary, length);
37126
37140
  imageStream.dictionary = dictionary;
37127
37141
  if (cacheKey !== undefined) {
37128
- this.imageCache[cacheKey] = imageStream; // eslint-disable-line
37142
+ this.imageCache.set(cacheKey, imageStream);
37129
37143
  }
37130
37144
  this.second = _PdfCommand.get('EI');
37131
37145
  this.shift();
@@ -42436,7 +42450,7 @@ class _XfdfDocument extends _ExportHelper {
42436
42450
  }
42437
42451
  }
42438
42452
  _writeObject(writer, primitive, dictionary, key) {
42439
- if (primitive) {
42453
+ if (primitive !== null && typeof primitive !== 'undefined') {
42440
42454
  if (primitive instanceof _PdfName) {
42441
42455
  this._writePrefix(writer, 'NAME', key);
42442
42456
  writer._writeAttributeString('VAL', primitive.name);
@@ -42661,6 +42675,7 @@ class _XfdfDocument extends _ExportHelper {
42661
42675
  case 'Vertices':
42662
42676
  case 'GroupNesting':
42663
42677
  case 'ITEx':
42678
+ case 'TextMarkupContent':
42664
42679
  break;
42665
42680
  default:
42666
42681
  this._writeAttributeString(writer, key.toLowerCase(), primitive);
@@ -42977,6 +42992,7 @@ class _XfdfDocument extends _ExportHelper {
42977
42992
  const annotations = page.annotations;
42978
42993
  const annotation = annotations._parseAnnotation(annotationDictionary);
42979
42994
  if (annotation) {
42995
+ annotation._isImported = true;
42980
42996
  const reference = this._crossReference._getNextReference();
42981
42997
  this._crossReference._cacheMap.set(reference, annotationDictionary);
42982
42998
  if (annotationDictionary.has('NM') || annotationDictionary.has('IRT')) {
@@ -43490,26 +43506,23 @@ class _XfdfDocument extends _ExportHelper {
43490
43506
  _addAppearanceData(element, dictionary) {
43491
43507
  const innerText = element.textContent;
43492
43508
  if (innerText && innerText !== '') {
43493
- const appearanceArray = _decode(innerText);
43494
- if (appearanceArray && appearanceArray.length > 0) {
43495
- const document = (new DOMParser()).parseFromString(_bytesToString(appearanceArray), 'text/xml');
43496
- if (document && document.hasChildNodes) {
43497
- let childNodes = document.childNodes;
43498
- if (childNodes && childNodes.length === 1) {
43499
- const rootNode = childNodes[0];
43500
- if (rootNode && rootNode.nodeType === 1) {
43501
- const rootElement = rootNode;
43502
- if (rootElement.nodeName.toLowerCase() === 'DICT' && rootElement.hasAttribute('KEY')) {
43503
- const key = rootElement.getAttribute('KEY');
43504
- if (key && key === 'AP' && rootElement.hasChildNodes) {
43505
- const appearance = new _PdfDictionary(this._crossReference);
43506
- childNodes = rootElement.childNodes;
43507
- for (let i = 0; i < childNodes.length; i++) {
43508
- this._getAppearance(appearance, childNodes[Number.parseInt(i.toString(), 10)]);
43509
- }
43510
- if (appearance.size > 0) {
43511
- dictionary.update('AP', appearance);
43512
- }
43509
+ const document = (new DOMParser()).parseFromString(atob(innerText), 'text/xml');
43510
+ if (document && document.hasChildNodes) {
43511
+ let childNodes = document.childNodes;
43512
+ if (childNodes && childNodes.length === 1) {
43513
+ const rootNode = childNodes[0];
43514
+ if (rootNode && rootNode.nodeType === 1) {
43515
+ const rootElement = rootNode;
43516
+ if (rootElement.nodeName.toUpperCase() === 'DICT' && rootElement.hasAttribute('KEY')) {
43517
+ const key = rootElement.getAttribute('KEY');
43518
+ if (key && key === 'AP' && rootElement.hasChildNodes) {
43519
+ const appearance = new _PdfDictionary(this._crossReference);
43520
+ childNodes = rootElement.childNodes;
43521
+ for (let i = 0; i < childNodes.length; i++) {
43522
+ this._getAppearance(appearance, childNodes[Number.parseInt(i.toString(), 10)]);
43523
+ }
43524
+ if (appearance.size > 0) {
43525
+ dictionary.update('AP', appearance);
43513
43526
  }
43514
43527
  }
43515
43528
  }
@@ -43539,7 +43552,7 @@ class _XfdfDocument extends _ExportHelper {
43539
43552
  dictionary = this._getDictionary(element);
43540
43553
  if (dictionary) {
43541
43554
  const reference = this._crossReference._getNextReference();
43542
- this._crossReference._cacheMap.set(reference, stream);
43555
+ this._crossReference._cacheMap.set(reference, dictionary);
43543
43556
  this._addKey(reference, appearance, element);
43544
43557
  }
43545
43558
  break;
@@ -44472,6 +44485,7 @@ class _JsonDocument extends _ExportHelper {
44472
44485
  case 'MeasurementTypes':
44473
44486
  case 'GroupNesting':
44474
44487
  case 'ITEx':
44488
+ case 'TextMarkupContent':
44475
44489
  break;
44476
44490
  case 'Border':
44477
44491
  case 'A':
@@ -47185,6 +47199,7 @@ class PdfDocument {
47185
47199
  this._hasUserPasswordOnly = false;
47186
47200
  this._encryptOnlyAttachment = false;
47187
47201
  this._encryptMetaData = false;
47202
+ this._isExport = false;
47188
47203
  this._allowCustomData = false;
47189
47204
  if (!data) {
47190
47205
  throw new Error('PDF data cannot be undefined or null');
@@ -47514,6 +47529,7 @@ class PdfDocument {
47514
47529
  });
47515
47530
  }
47516
47531
  exportAnnotations(arg1, arg2) {
47532
+ this._isExport = true;
47517
47533
  this._doPostProcessOnAnnotations();
47518
47534
  let helper;
47519
47535
  let settings;
@@ -47780,6 +47796,7 @@ class PdfDocument {
47780
47796
  _doPostProcessOnAnnotations(isFlatten = false) {
47781
47797
  for (let i = 0; i < this.pageCount; i++) {
47782
47798
  const page = this.getPage(i);
47799
+ page.annotations._isExport = this._isExport;
47783
47800
  page.annotations._doPostProcess(isFlatten);
47784
47801
  if (isFlatten) {
47785
47802
  if (page._pageDictionary.has('Annots')) {