@syncfusion/ej2-pdf 23.1.38 → 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.
@@ -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;
@@ -23763,11 +23764,11 @@ var PdfRubberStampAnnotation = /** @__PURE__ @class */ (function (_super) {
23763
23764
  PdfRubberStampAnnotation.prototype._doPostProcess = function (isFlatten) {
23764
23765
  if (isFlatten === void 0) { isFlatten = false; }
23765
23766
  var isTransformBBox = false;
23766
- if (this._isLoaded && (this._setAppearance || isFlatten)) {
23767
- if (!isFlatten) {
23767
+ if (this._isLoaded && (this._setAppearance || isFlatten || this._isExport)) {
23768
+ if ((!isFlatten && !this._isExport) || this._setAppearance) {
23768
23769
  this._appearanceTemplate = this._createRubberStampAppearance();
23769
23770
  }
23770
- if (!this._appearanceTemplate && isFlatten && this._dictionary.has('AP')) {
23771
+ if (!this._appearanceTemplate && (this._isExport || isFlatten) && this._dictionary.has('AP')) {
23771
23772
  var dictionary = this._dictionary.get('AP');
23772
23773
  if (dictionary && dictionary.has('N')) {
23773
23774
  var appearanceStream = dictionary.get('N');
@@ -23824,8 +23825,10 @@ var PdfRubberStampAnnotation = /** @__PURE__ @class */ (function (_super) {
23824
23825
  }
23825
23826
  }
23826
23827
  else {
23827
- this._postProcess();
23828
- if ((!this._appearanceTemplate) && isFlatten) {
23828
+ if (!(this._isImported && this._dictionary.has('AP'))) {
23829
+ this._postProcess();
23830
+ }
23831
+ if ((!this._appearanceTemplate) && (isFlatten || this._isImported)) {
23829
23832
  if (!this._dictionary.has('AP')) {
23830
23833
  this._appearanceTemplate = this._createRubberStampAppearance();
23831
23834
  }
@@ -28302,6 +28305,7 @@ var PdfAnnotationCollection = /** @__PURE__ @class */ (function () {
28302
28305
  * @param {PdfPage} page PDF page object.
28303
28306
  */
28304
28307
  function PdfAnnotationCollection(array, xref, page) {
28308
+ this._isExport = false;
28305
28309
  this._annotations = array;
28306
28310
  this._page = page;
28307
28311
  this._crossReference = xref;
@@ -28695,6 +28699,7 @@ var PdfAnnotationCollection = /** @__PURE__ @class */ (function () {
28695
28699
  for (var i = this.count - 1; i >= 0; i--) {
28696
28700
  var annotation = this.at(i);
28697
28701
  if (annotation) {
28702
+ annotation._isExport = this._isExport;
28698
28703
  annotation._doPostProcess(annotation.flatten || isFlatten);
28699
28704
  }
28700
28705
  }
@@ -38936,21 +38941,21 @@ var _PdfEncryptor = /** @__PURE__ @class */ (function () {
38936
38941
  else {
38937
38942
  algorithm_1 = new _BasicEncryption();
38938
38943
  }
38939
- var password_1;
38944
+ var p = void 0;
38940
38945
  if (passwordBytes) {
38941
- password_1 = passwordBytes.subarray(0, Math.min(127, passwordBytes.length));
38946
+ p = passwordBytes.subarray(0, Math.min(127, passwordBytes.length));
38942
38947
  }
38943
38948
  else {
38944
- password_1 = new Uint8Array([]);
38949
+ p = new Uint8Array([]);
38945
38950
  }
38946
- if (algorithm_1._checkUserPassword(password_1, userValidationSalt, userPassword)) {
38947
- encryptionKey = this._createEncryptionKey(true, password_1, ownerKeySalt, uBytes, userKeySalt, ownerEncryption, userEncryption, algorithm_1);
38951
+ if (algorithm_1._checkUserPassword(p, userValidationSalt, userPassword)) {
38952
+ encryptionKey = this._createEncryptionKey(true, p, ownerKeySalt, uBytes, userKeySalt, ownerEncryption, userEncryption, algorithm_1);
38948
38953
  this._isUserPassword = true;
38949
- if (password_1.length && algorithm_1._checkOwnerPassword(password_1, ownerValidationSalt, uBytes, ownerPassword)) {
38954
+ if (password.length && algorithm_1._checkOwnerPassword(p, ownerValidationSalt, uBytes, ownerPassword)) {
38950
38955
  this._hasUserPasswordOnly = true;
38951
38956
  }
38952
38957
  }
38953
- else if (password_1.length && algorithm_1._checkOwnerPassword(password_1, ownerValidationSalt, uBytes, ownerPassword)) {
38958
+ else if (password.length && algorithm_1._checkOwnerPassword(p, ownerValidationSalt, uBytes, ownerPassword)) {
38954
38959
  encryptionKey = this._createEncryptionKey(false, passwordBytes, ownerKeySalt, uBytes, userKeySalt, ownerEncryption, userEncryption, algorithm_1);
38955
38960
  this._isUserPassword = false;
38956
38961
  }
@@ -38965,7 +38970,6 @@ var _PdfEncryptor = /** @__PURE__ @class */ (function () {
38965
38970
  throw new Error('Cannot open an encrypted document. The password is invalid.');
38966
38971
  }
38967
38972
  }
38968
- this._encryptionKey = encryptionKey;
38969
38973
  if (algorithm >= 4) {
38970
38974
  var cipherDictionary = dictionary.get('CF');
38971
38975
  if (cipherDictionary) {
@@ -38985,6 +38989,10 @@ var _PdfEncryptor = /** @__PURE__ @class */ (function () {
38985
38989
  this._string = dictionary.get('StrF') || _PdfName.get('Identity');
38986
38990
  this._eff = dictionary.get('EFF') || this._stream;
38987
38991
  }
38992
+ if (!encryptionKey && !this._encryptOnlyAttachment) {
38993
+ throw new Error('Cannot open an encrypted document. The password is invalid.');
38994
+ }
38995
+ this._encryptionKey = encryptionKey;
38988
38996
  }
38989
38997
  Object.defineProperty(_PdfEncryptor.prototype, "_md5", {
38990
38998
  get: function () {
@@ -40377,7 +40385,7 @@ var _AdvancedEncryption256Cipher = /** @__PURE__ @class */ (function (_super) {
40377
40385
  }
40378
40386
  }
40379
40387
  for (var n = 0; n < 4; ++n) {
40380
- result[Number.parseInt(i.toString(), 10)] = t1 ^= result[j - 32];
40388
+ result[Number.parseInt(j.toString(), 10)] = t1 ^= result[j - 32];
40381
40389
  result[j + 1] = t2 ^= result[j - 31];
40382
40390
  result[j + 2] = t3 ^= result[j - 30];
40383
40391
  result[j + 3] = t4 ^= result[j - 29];
@@ -44042,7 +44050,7 @@ var _XfdfDocument = /** @__PURE__ @class */ (function (_super) {
44042
44050
  }
44043
44051
  };
44044
44052
  _XfdfDocument.prototype._writeObject = function (writer, primitive, dictionary, key) {
44045
- if (primitive) {
44053
+ if (primitive !== null && typeof primitive !== 'undefined') {
44046
44054
  if (primitive instanceof _PdfName) {
44047
44055
  this._writePrefix(writer, 'NAME', key);
44048
44056
  writer._writeAttributeString('VAL', primitive.name);
@@ -44269,6 +44277,7 @@ var _XfdfDocument = /** @__PURE__ @class */ (function (_super) {
44269
44277
  case 'Vertices':
44270
44278
  case 'GroupNesting':
44271
44279
  case 'ITEx':
44280
+ case 'TextMarkupContent':
44272
44281
  break;
44273
44282
  default:
44274
44283
  this._writeAttributeString(writer, key.toLowerCase(), primitive);
@@ -44586,6 +44595,7 @@ var _XfdfDocument = /** @__PURE__ @class */ (function (_super) {
44586
44595
  var annotations = page.annotations;
44587
44596
  var annotation = annotations._parseAnnotation(annotationDictionary);
44588
44597
  if (annotation) {
44598
+ annotation._isImported = true;
44589
44599
  var reference = this._crossReference._getNextReference();
44590
44600
  this._crossReference._cacheMap.set(reference, annotationDictionary);
44591
44601
  if (annotationDictionary.has('NM') || annotationDictionary.has('IRT')) {
@@ -45106,26 +45116,23 @@ var _XfdfDocument = /** @__PURE__ @class */ (function (_super) {
45106
45116
  _XfdfDocument.prototype._addAppearanceData = function (element, dictionary) {
45107
45117
  var innerText = element.textContent;
45108
45118
  if (innerText && innerText !== '') {
45109
- var appearanceArray = _decode(innerText);
45110
- if (appearanceArray && appearanceArray.length > 0) {
45111
- var document_1 = (new DOMParser()).parseFromString(_bytesToString(appearanceArray), 'text/xml');
45112
- if (document_1 && document_1.hasChildNodes) {
45113
- var childNodes = document_1.childNodes;
45114
- if (childNodes && childNodes.length === 1) {
45115
- var rootNode = childNodes[0];
45116
- if (rootNode && rootNode.nodeType === 1) {
45117
- var rootElement = rootNode;
45118
- if (rootElement.nodeName.toLowerCase() === 'DICT' && rootElement.hasAttribute('KEY')) {
45119
- var key = rootElement.getAttribute('KEY');
45120
- if (key && key === 'AP' && rootElement.hasChildNodes) {
45121
- var appearance = new _PdfDictionary(this._crossReference);
45122
- childNodes = rootElement.childNodes;
45123
- for (var i = 0; i < childNodes.length; i++) {
45124
- this._getAppearance(appearance, childNodes[Number.parseInt(i.toString(), 10)]);
45125
- }
45126
- if (appearance.size > 0) {
45127
- dictionary.update('AP', appearance);
45128
- }
45119
+ var document_1 = (new DOMParser()).parseFromString(atob(innerText), 'text/xml');
45120
+ if (document_1 && document_1.hasChildNodes) {
45121
+ var childNodes = document_1.childNodes;
45122
+ if (childNodes && childNodes.length === 1) {
45123
+ var rootNode = childNodes[0];
45124
+ if (rootNode && rootNode.nodeType === 1) {
45125
+ var rootElement = rootNode;
45126
+ if (rootElement.nodeName.toUpperCase() === 'DICT' && rootElement.hasAttribute('KEY')) {
45127
+ var key = rootElement.getAttribute('KEY');
45128
+ if (key && key === 'AP' && rootElement.hasChildNodes) {
45129
+ var appearance = new _PdfDictionary(this._crossReference);
45130
+ childNodes = rootElement.childNodes;
45131
+ for (var i = 0; i < childNodes.length; i++) {
45132
+ this._getAppearance(appearance, childNodes[Number.parseInt(i.toString(), 10)]);
45133
+ }
45134
+ if (appearance.size > 0) {
45135
+ dictionary.update('AP', appearance);
45129
45136
  }
45130
45137
  }
45131
45138
  }
@@ -45155,7 +45162,7 @@ var _XfdfDocument = /** @__PURE__ @class */ (function (_super) {
45155
45162
  dictionary = this._getDictionary(element);
45156
45163
  if (dictionary) {
45157
45164
  var reference = this._crossReference._getNextReference();
45158
- this._crossReference._cacheMap.set(reference, stream);
45165
+ this._crossReference._cacheMap.set(reference, dictionary);
45159
45166
  this._addKey(reference, appearance, element);
45160
45167
  }
45161
45168
  break;
@@ -46125,6 +46132,7 @@ var _JsonDocument = /** @__PURE__ @class */ (function (_super) {
46125
46132
  case 'MeasurementTypes':
46126
46133
  case 'GroupNesting':
46127
46134
  case 'ITEx':
46135
+ case 'TextMarkupContent':
46128
46136
  break;
46129
46137
  case 'Border':
46130
46138
  case 'A':
@@ -48961,6 +48969,7 @@ var PdfDocument = /** @__PURE__ @class */ (function () {
48961
48969
  this._hasUserPasswordOnly = false;
48962
48970
  this._encryptOnlyAttachment = false;
48963
48971
  this._encryptMetaData = false;
48972
+ this._isExport = false;
48964
48973
  this._allowCustomData = false;
48965
48974
  if (!data) {
48966
48975
  throw new Error('PDF data cannot be undefined or null');
@@ -49335,6 +49344,7 @@ var PdfDocument = /** @__PURE__ @class */ (function () {
49335
49344
  });
49336
49345
  };
49337
49346
  PdfDocument.prototype.exportAnnotations = function (arg1, arg2) {
49347
+ this._isExport = true;
49338
49348
  this._doPostProcessOnAnnotations();
49339
49349
  var helper;
49340
49350
  var settings;
@@ -49610,6 +49620,7 @@ var PdfDocument = /** @__PURE__ @class */ (function () {
49610
49620
  if (isFlatten === void 0) { isFlatten = false; }
49611
49621
  for (var i = 0; i < this.pageCount; i++) {
49612
49622
  var page = this.getPage(i);
49623
+ page.annotations._isExport = this._isExport;
49613
49624
  page.annotations._doPostProcess(isFlatten);
49614
49625
  if (isFlatten) {
49615
49626
  if (page._pageDictionary.has('Annots')) {