@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.
@@ -14164,6 +14164,7 @@ var PdfAnnotation = /** @__PURE__ @class */ (function () {
14164
14164
  this._isImported = false;
14165
14165
  this._isLoaded = false;
14166
14166
  this._setAppearance = false;
14167
+ this._isExport = false;
14167
14168
  this._opacity = 1;
14168
14169
  this._isAllRotation = true;
14169
14170
  this._flatten = false;
@@ -22213,12 +22214,17 @@ var PdfDocumentLinkAnnotation = /** @__PURE__ @class */ (function (_super) {
22213
22214
  else if (this._dictionary.has('A') && !this._destination) {
22214
22215
  var action = this._dictionary.get('A');
22215
22216
  if (action.has('D')) {
22216
- var reference = action.get('D');
22217
- if (reference) {
22218
- var referenceValue = this._crossReference._fetch(reference); // eslint-disable-line
22217
+ var reference = action.get('D'); // eslint-disable-line
22218
+ if (reference !== null && typeof reference !== 'undefined') {
22219
22219
  var referenceArray = void 0; // eslint-disable-line
22220
- if (Array.isArray(referenceValue)) {
22221
- referenceArray = referenceValue;
22220
+ if (Array.isArray(reference)) {
22221
+ referenceArray = reference;
22222
+ }
22223
+ else if (reference instanceof _PdfReference) {
22224
+ var referenceValue = this._crossReference._fetch(reference); // eslint-disable-line
22225
+ if (Array.isArray(referenceValue)) {
22226
+ referenceArray = referenceValue;
22227
+ }
22222
22228
  }
22223
22229
  if (referenceArray) {
22224
22230
  if (referenceArray[0] instanceof _PdfReference) {
@@ -23763,11 +23769,11 @@ var PdfRubberStampAnnotation = /** @__PURE__ @class */ (function (_super) {
23763
23769
  PdfRubberStampAnnotation.prototype._doPostProcess = function (isFlatten) {
23764
23770
  if (isFlatten === void 0) { isFlatten = false; }
23765
23771
  var isTransformBBox = false;
23766
- if (this._isLoaded && (this._setAppearance || isFlatten)) {
23767
- if (!isFlatten) {
23772
+ if (this._isLoaded && (this._setAppearance || isFlatten || this._isExport)) {
23773
+ if ((!isFlatten && !this._isExport) || this._setAppearance) {
23768
23774
  this._appearanceTemplate = this._createRubberStampAppearance();
23769
23775
  }
23770
- if (!this._appearanceTemplate && isFlatten && this._dictionary.has('AP')) {
23776
+ if (!this._appearanceTemplate && (this._isExport || isFlatten) && this._dictionary.has('AP')) {
23771
23777
  var dictionary = this._dictionary.get('AP');
23772
23778
  if (dictionary && dictionary.has('N')) {
23773
23779
  var appearanceStream = dictionary.get('N');
@@ -23824,8 +23830,10 @@ var PdfRubberStampAnnotation = /** @__PURE__ @class */ (function (_super) {
23824
23830
  }
23825
23831
  }
23826
23832
  else {
23827
- this._postProcess();
23828
- if ((!this._appearanceTemplate) && isFlatten) {
23833
+ if (!(this._isImported && this._dictionary.has('AP'))) {
23834
+ this._postProcess();
23835
+ }
23836
+ if ((!this._appearanceTemplate) && (isFlatten || this._isImported)) {
23829
23837
  if (!this._dictionary.has('AP')) {
23830
23838
  this._appearanceTemplate = this._createRubberStampAppearance();
23831
23839
  }
@@ -28302,6 +28310,7 @@ var PdfAnnotationCollection = /** @__PURE__ @class */ (function () {
28302
28310
  * @param {PdfPage} page PDF page object.
28303
28311
  */
28304
28312
  function PdfAnnotationCollection(array, xref, page) {
28313
+ this._isExport = false;
28305
28314
  this._annotations = array;
28306
28315
  this._page = page;
28307
28316
  this._crossReference = xref;
@@ -28695,6 +28704,7 @@ var PdfAnnotationCollection = /** @__PURE__ @class */ (function () {
28695
28704
  for (var i = this.count - 1; i >= 0; i--) {
28696
28705
  var annotation = this.at(i);
28697
28706
  if (annotation) {
28707
+ annotation._isExport = this._isExport;
28698
28708
  annotation._doPostProcess(annotation.flatten || isFlatten);
28699
28709
  }
28700
28710
  }
@@ -37479,12 +37489,8 @@ var _PdfCatalog = /** @__PURE__ @class */ (function () {
37479
37489
  if (this._catalogDictionary.has('AcroForm')) {
37480
37490
  form = this._catalogDictionary.get('AcroForm');
37481
37491
  }
37482
- else {
37483
- form = new _PdfDictionary(this._crossReference);
37484
- var ref = this._crossReference._getNextReference();
37485
- this._crossReference._cacheMap.set(ref, form);
37486
- this._catalogDictionary.set('AcroForm', ref);
37487
- this._catalogDictionary._updated = true;
37492
+ if (form === null || typeof form === 'undefined') {
37493
+ form = this._createForm();
37488
37494
  }
37489
37495
  return form;
37490
37496
  },
@@ -37492,6 +37498,14 @@ var _PdfCatalog = /** @__PURE__ @class */ (function () {
37492
37498
  configurable: true
37493
37499
  });
37494
37500
  /* eslint-disable */
37501
+ _PdfCatalog.prototype._createForm = function () {
37502
+ var form = new _PdfDictionary(this._crossReference);
37503
+ var ref = this._crossReference._getNextReference();
37504
+ this._crossReference._cacheMap.set(ref, form);
37505
+ this._catalogDictionary.set('AcroForm', ref);
37506
+ this._catalogDictionary._updated = true;
37507
+ return form;
37508
+ };
37495
37509
  _PdfCatalog.prototype.getPageDictionary = function (pageIndex) {
37496
37510
  var nodesToVisit = [this._topPagesDictionary];
37497
37511
  var visitedNodes = new _PdfReferenceSet();
@@ -38568,7 +38582,7 @@ var _PdfParser = /** @__PURE__ @class */ (function () {
38568
38582
  var dictBytes = stream.getBytes(dictLength);
38569
38583
  stream.position = initialStreamPos;
38570
38584
  cacheKey = this._computeMaxNumber(imageBytes) + '_' + this._computeMaxNumber(dictBytes);
38571
- var cacheEntry = this.imageCache[cacheKey]; // eslint-disable-line
38585
+ var cacheEntry = this.imageCache.get(cacheKey);
38572
38586
  if (cacheEntry !== undefined) {
38573
38587
  this.second = _PdfCommand.get('EI');
38574
38588
  this.shift();
@@ -38582,7 +38596,7 @@ var _PdfParser = /** @__PURE__ @class */ (function () {
38582
38596
  imageStream = this.filter(imageStream, dictionary, length);
38583
38597
  imageStream.dictionary = dictionary;
38584
38598
  if (cacheKey !== undefined) {
38585
- this.imageCache[cacheKey] = imageStream; // eslint-disable-line
38599
+ this.imageCache.set(cacheKey, imageStream);
38586
38600
  }
38587
38601
  this.second = _PdfCommand.get('EI');
38588
38602
  this.shift();
@@ -44045,7 +44059,7 @@ var _XfdfDocument = /** @__PURE__ @class */ (function (_super) {
44045
44059
  }
44046
44060
  };
44047
44061
  _XfdfDocument.prototype._writeObject = function (writer, primitive, dictionary, key) {
44048
- if (primitive) {
44062
+ if (primitive !== null && typeof primitive !== 'undefined') {
44049
44063
  if (primitive instanceof _PdfName) {
44050
44064
  this._writePrefix(writer, 'NAME', key);
44051
44065
  writer._writeAttributeString('VAL', primitive.name);
@@ -44272,6 +44286,7 @@ var _XfdfDocument = /** @__PURE__ @class */ (function (_super) {
44272
44286
  case 'Vertices':
44273
44287
  case 'GroupNesting':
44274
44288
  case 'ITEx':
44289
+ case 'TextMarkupContent':
44275
44290
  break;
44276
44291
  default:
44277
44292
  this._writeAttributeString(writer, key.toLowerCase(), primitive);
@@ -44589,6 +44604,7 @@ var _XfdfDocument = /** @__PURE__ @class */ (function (_super) {
44589
44604
  var annotations = page.annotations;
44590
44605
  var annotation = annotations._parseAnnotation(annotationDictionary);
44591
44606
  if (annotation) {
44607
+ annotation._isImported = true;
44592
44608
  var reference = this._crossReference._getNextReference();
44593
44609
  this._crossReference._cacheMap.set(reference, annotationDictionary);
44594
44610
  if (annotationDictionary.has('NM') || annotationDictionary.has('IRT')) {
@@ -45109,26 +45125,23 @@ var _XfdfDocument = /** @__PURE__ @class */ (function (_super) {
45109
45125
  _XfdfDocument.prototype._addAppearanceData = function (element, dictionary) {
45110
45126
  var innerText = element.textContent;
45111
45127
  if (innerText && innerText !== '') {
45112
- var appearanceArray = _decode(innerText);
45113
- if (appearanceArray && appearanceArray.length > 0) {
45114
- var document_1 = (new DOMParser()).parseFromString(_bytesToString(appearanceArray), 'text/xml');
45115
- if (document_1 && document_1.hasChildNodes) {
45116
- var childNodes = document_1.childNodes;
45117
- if (childNodes && childNodes.length === 1) {
45118
- var rootNode = childNodes[0];
45119
- if (rootNode && rootNode.nodeType === 1) {
45120
- var rootElement = rootNode;
45121
- if (rootElement.nodeName.toLowerCase() === 'DICT' && rootElement.hasAttribute('KEY')) {
45122
- var key = rootElement.getAttribute('KEY');
45123
- if (key && key === 'AP' && rootElement.hasChildNodes) {
45124
- var appearance = new _PdfDictionary(this._crossReference);
45125
- childNodes = rootElement.childNodes;
45126
- for (var i = 0; i < childNodes.length; i++) {
45127
- this._getAppearance(appearance, childNodes[Number.parseInt(i.toString(), 10)]);
45128
- }
45129
- if (appearance.size > 0) {
45130
- dictionary.update('AP', appearance);
45131
- }
45128
+ var document_1 = (new DOMParser()).parseFromString(atob(innerText), 'text/xml');
45129
+ if (document_1 && document_1.hasChildNodes) {
45130
+ var childNodes = document_1.childNodes;
45131
+ if (childNodes && childNodes.length === 1) {
45132
+ var rootNode = childNodes[0];
45133
+ if (rootNode && rootNode.nodeType === 1) {
45134
+ var rootElement = rootNode;
45135
+ if (rootElement.nodeName.toUpperCase() === 'DICT' && rootElement.hasAttribute('KEY')) {
45136
+ var key = rootElement.getAttribute('KEY');
45137
+ if (key && key === 'AP' && rootElement.hasChildNodes) {
45138
+ var appearance = new _PdfDictionary(this._crossReference);
45139
+ childNodes = rootElement.childNodes;
45140
+ for (var i = 0; i < childNodes.length; i++) {
45141
+ this._getAppearance(appearance, childNodes[Number.parseInt(i.toString(), 10)]);
45142
+ }
45143
+ if (appearance.size > 0) {
45144
+ dictionary.update('AP', appearance);
45132
45145
  }
45133
45146
  }
45134
45147
  }
@@ -45158,7 +45171,7 @@ var _XfdfDocument = /** @__PURE__ @class */ (function (_super) {
45158
45171
  dictionary = this._getDictionary(element);
45159
45172
  if (dictionary) {
45160
45173
  var reference = this._crossReference._getNextReference();
45161
- this._crossReference._cacheMap.set(reference, stream);
45174
+ this._crossReference._cacheMap.set(reference, dictionary);
45162
45175
  this._addKey(reference, appearance, element);
45163
45176
  }
45164
45177
  break;
@@ -46128,6 +46141,7 @@ var _JsonDocument = /** @__PURE__ @class */ (function (_super) {
46128
46141
  case 'MeasurementTypes':
46129
46142
  case 'GroupNesting':
46130
46143
  case 'ITEx':
46144
+ case 'TextMarkupContent':
46131
46145
  break;
46132
46146
  case 'Border':
46133
46147
  case 'A':
@@ -48964,6 +48978,7 @@ var PdfDocument = /** @__PURE__ @class */ (function () {
48964
48978
  this._hasUserPasswordOnly = false;
48965
48979
  this._encryptOnlyAttachment = false;
48966
48980
  this._encryptMetaData = false;
48981
+ this._isExport = false;
48967
48982
  this._allowCustomData = false;
48968
48983
  if (!data) {
48969
48984
  throw new Error('PDF data cannot be undefined or null');
@@ -49338,6 +49353,7 @@ var PdfDocument = /** @__PURE__ @class */ (function () {
49338
49353
  });
49339
49354
  };
49340
49355
  PdfDocument.prototype.exportAnnotations = function (arg1, arg2) {
49356
+ this._isExport = true;
49341
49357
  this._doPostProcessOnAnnotations();
49342
49358
  var helper;
49343
49359
  var settings;
@@ -49613,6 +49629,7 @@ var PdfDocument = /** @__PURE__ @class */ (function () {
49613
49629
  if (isFlatten === void 0) { isFlatten = false; }
49614
49630
  for (var i = 0; i < this.pageCount; i++) {
49615
49631
  var page = this.getPage(i);
49632
+ page.annotations._isExport = this._isExport;
49616
49633
  page.annotations._doPostProcess(isFlatten);
49617
49634
  if (isFlatten) {
49618
49635
  if (page._pageDictionary.has('Annots')) {