@syncfusion/ej2-pdf 23.1.39 → 23.1.44

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;
@@ -22841,11 +22842,11 @@ class PdfRubberStampAnnotation extends PdfComment {
22841
22842
  }
22842
22843
  _doPostProcess(isFlatten = false) {
22843
22844
  let isTransformBBox = false;
22844
- if (this._isLoaded && (this._setAppearance || isFlatten)) {
22845
- if (!isFlatten) {
22845
+ if (this._isLoaded && (this._setAppearance || isFlatten || this._isExport)) {
22846
+ if ((!isFlatten && !this._isExport) || this._setAppearance) {
22846
22847
  this._appearanceTemplate = this._createRubberStampAppearance();
22847
22848
  }
22848
- if (!this._appearanceTemplate && isFlatten && this._dictionary.has('AP')) {
22849
+ if (!this._appearanceTemplate && (this._isExport || isFlatten) && this._dictionary.has('AP')) {
22849
22850
  const dictionary = this._dictionary.get('AP');
22850
22851
  if (dictionary && dictionary.has('N')) {
22851
22852
  const appearanceStream = dictionary.get('N');
@@ -22902,8 +22903,10 @@ class PdfRubberStampAnnotation extends PdfComment {
22902
22903
  }
22903
22904
  }
22904
22905
  else {
22905
- this._postProcess();
22906
- if ((!this._appearanceTemplate) && isFlatten) {
22906
+ if (!(this._isImported && this._dictionary.has('AP'))) {
22907
+ this._postProcess();
22908
+ }
22909
+ if ((!this._appearanceTemplate) && (isFlatten || this._isImported)) {
22907
22910
  if (!this._dictionary.has('AP')) {
22908
22911
  this._appearanceTemplate = this._createRubberStampAppearance();
22909
22912
  }
@@ -27161,6 +27164,7 @@ class PdfAnnotationCollection {
27161
27164
  * @param {PdfPage} page PDF page object.
27162
27165
  */
27163
27166
  constructor(array, xref, page) {
27167
+ this._isExport = false;
27164
27168
  this._annotations = array;
27165
27169
  this._page = page;
27166
27170
  this._crossReference = xref;
@@ -27550,6 +27554,7 @@ class PdfAnnotationCollection {
27550
27554
  for (let i = this.count - 1; i >= 0; i--) {
27551
27555
  const annotation = this.at(i);
27552
27556
  if (annotation) {
27557
+ annotation._isExport = this._isExport;
27553
27558
  annotation._doPostProcess(annotation.flatten || isFlatten);
27554
27559
  }
27555
27560
  }
@@ -42436,7 +42441,7 @@ class _XfdfDocument extends _ExportHelper {
42436
42441
  }
42437
42442
  }
42438
42443
  _writeObject(writer, primitive, dictionary, key) {
42439
- if (primitive) {
42444
+ if (primitive !== null && typeof primitive !== 'undefined') {
42440
42445
  if (primitive instanceof _PdfName) {
42441
42446
  this._writePrefix(writer, 'NAME', key);
42442
42447
  writer._writeAttributeString('VAL', primitive.name);
@@ -42661,6 +42666,7 @@ class _XfdfDocument extends _ExportHelper {
42661
42666
  case 'Vertices':
42662
42667
  case 'GroupNesting':
42663
42668
  case 'ITEx':
42669
+ case 'TextMarkupContent':
42664
42670
  break;
42665
42671
  default:
42666
42672
  this._writeAttributeString(writer, key.toLowerCase(), primitive);
@@ -42977,6 +42983,7 @@ class _XfdfDocument extends _ExportHelper {
42977
42983
  const annotations = page.annotations;
42978
42984
  const annotation = annotations._parseAnnotation(annotationDictionary);
42979
42985
  if (annotation) {
42986
+ annotation._isImported = true;
42980
42987
  const reference = this._crossReference._getNextReference();
42981
42988
  this._crossReference._cacheMap.set(reference, annotationDictionary);
42982
42989
  if (annotationDictionary.has('NM') || annotationDictionary.has('IRT')) {
@@ -43490,26 +43497,23 @@ class _XfdfDocument extends _ExportHelper {
43490
43497
  _addAppearanceData(element, dictionary) {
43491
43498
  const innerText = element.textContent;
43492
43499
  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
- }
43500
+ const document = (new DOMParser()).parseFromString(atob(innerText), 'text/xml');
43501
+ if (document && document.hasChildNodes) {
43502
+ let childNodes = document.childNodes;
43503
+ if (childNodes && childNodes.length === 1) {
43504
+ const rootNode = childNodes[0];
43505
+ if (rootNode && rootNode.nodeType === 1) {
43506
+ const rootElement = rootNode;
43507
+ if (rootElement.nodeName.toUpperCase() === 'DICT' && rootElement.hasAttribute('KEY')) {
43508
+ const key = rootElement.getAttribute('KEY');
43509
+ if (key && key === 'AP' && rootElement.hasChildNodes) {
43510
+ const appearance = new _PdfDictionary(this._crossReference);
43511
+ childNodes = rootElement.childNodes;
43512
+ for (let i = 0; i < childNodes.length; i++) {
43513
+ this._getAppearance(appearance, childNodes[Number.parseInt(i.toString(), 10)]);
43514
+ }
43515
+ if (appearance.size > 0) {
43516
+ dictionary.update('AP', appearance);
43513
43517
  }
43514
43518
  }
43515
43519
  }
@@ -43539,7 +43543,7 @@ class _XfdfDocument extends _ExportHelper {
43539
43543
  dictionary = this._getDictionary(element);
43540
43544
  if (dictionary) {
43541
43545
  const reference = this._crossReference._getNextReference();
43542
- this._crossReference._cacheMap.set(reference, stream);
43546
+ this._crossReference._cacheMap.set(reference, dictionary);
43543
43547
  this._addKey(reference, appearance, element);
43544
43548
  }
43545
43549
  break;
@@ -44472,6 +44476,7 @@ class _JsonDocument extends _ExportHelper {
44472
44476
  case 'MeasurementTypes':
44473
44477
  case 'GroupNesting':
44474
44478
  case 'ITEx':
44479
+ case 'TextMarkupContent':
44475
44480
  break;
44476
44481
  case 'Border':
44477
44482
  case 'A':
@@ -47185,6 +47190,7 @@ class PdfDocument {
47185
47190
  this._hasUserPasswordOnly = false;
47186
47191
  this._encryptOnlyAttachment = false;
47187
47192
  this._encryptMetaData = false;
47193
+ this._isExport = false;
47188
47194
  this._allowCustomData = false;
47189
47195
  if (!data) {
47190
47196
  throw new Error('PDF data cannot be undefined or null');
@@ -47514,6 +47520,7 @@ class PdfDocument {
47514
47520
  });
47515
47521
  }
47516
47522
  exportAnnotations(arg1, arg2) {
47523
+ this._isExport = true;
47517
47524
  this._doPostProcessOnAnnotations();
47518
47525
  let helper;
47519
47526
  let settings;
@@ -47780,6 +47787,7 @@ class PdfDocument {
47780
47787
  _doPostProcessOnAnnotations(isFlatten = false) {
47781
47788
  for (let i = 0; i < this.pageCount; i++) {
47782
47789
  const page = this.getPage(i);
47790
+ page.annotations._isExport = this._isExport;
47783
47791
  page.annotations._doPostProcess(isFlatten);
47784
47792
  if (isFlatten) {
47785
47793
  if (page._pageDictionary.has('Annots')) {