@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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * filename: index.d.ts
3
- * version : 23.1.38
3
+ * version : 23.1.44
4
4
  * Copyright Syncfusion Inc. 2001 - 2023. All rights reserved.
5
5
  * Use of this code is subject to the terms of our license.
6
6
  * A copy of the current license can be obtained at any time by e-mailing
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "_from": "@syncfusion/ej2-pdf@*",
3
- "_id": "@syncfusion/ej2-pdf@23.1.36",
3
+ "_id": "@syncfusion/ej2-pdf@23.1.39",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-UxecW8YkOzEjWhPgZkAUw8nzEM9h+f7FgHWcrp4hWkhT+4+2nAlGwVuZFBfNQlQnFmP48qIoefBjCzYdKAKOXA==",
5
+ "_integrity": "sha512-tLY2W2Z0Idbb5+dT440TVLK1i0RojV+BeOXnrJpWFrAvEKCfoK+2+EszHgYTh8mnWzcxESqfx72VCaX7Qkr4nA==",
6
6
  "_location": "/@syncfusion/ej2-pdf",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -21,8 +21,8 @@
21
21
  "/@syncfusion/ej2",
22
22
  "/@syncfusion/ej2-pdfviewer"
23
23
  ],
24
- "_resolved": "https://nexus.syncfusion.com/repository/ej2-hotfix-new/@syncfusion/ej2-pdf/-/ej2-pdf-23.1.36.tgz",
25
- "_shasum": "c692c77b2b0ef1c720b95c073508daaa6e63a2c2",
24
+ "_resolved": "https://nexus.syncfusion.com/repository/ej2-hotfix-new/@syncfusion/ej2-pdf/-/ej2-pdf-23.1.39.tgz",
25
+ "_shasum": "129bc305e8eb6be65112ce8aa75144fa102445e8",
26
26
  "_spec": "@syncfusion/ej2-pdf@*",
27
27
  "_where": "/jenkins/workspace/elease-automation_release_23.1.1/packages/included",
28
28
  "author": {
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "bundleDependencies": false,
32
32
  "dependencies": {
33
- "@syncfusion/ej2-base": "~23.1.38",
33
+ "@syncfusion/ej2-base": "~23.1.41",
34
34
  "@syncfusion/ej2-compression": "~23.1.36"
35
35
  },
36
36
  "deprecated": false,
@@ -55,7 +55,7 @@
55
55
  "url": "https://github.com/syncfusion/ej2-javascript-ui-controls/tree/master/controls/pdf"
56
56
  },
57
57
  "typings": "index.d.ts",
58
- "version": "23.1.38",
58
+ "version": "23.1.44",
59
59
  "sideEffects": false,
60
60
  "homepage": "https://www.syncfusion.com/javascript-ui-controls"
61
61
  }
@@ -19,6 +19,7 @@ export declare class PdfAnnotationCollection {
19
19
  _annotations: Array<_PdfReference>;
20
20
  _comments: Array<PdfPopupAnnotation>;
21
21
  _parsedAnnotations: Map<number, PdfAnnotation>;
22
+ _isExport: boolean;
22
23
  private _page;
23
24
  private _crossReference;
24
25
  /**
@@ -25,6 +25,7 @@ var PdfAnnotationCollection = /** @class */ (function () {
25
25
  * @param {PdfPage} page PDF page object.
26
26
  */
27
27
  function PdfAnnotationCollection(array, xref, page) {
28
+ this._isExport = false;
28
29
  this._annotations = array;
29
30
  this._page = page;
30
31
  this._crossReference = xref;
@@ -418,6 +419,7 @@ var PdfAnnotationCollection = /** @class */ (function () {
418
419
  for (var i = this.count - 1; i >= 0; i--) {
419
420
  var annotation = this.at(i);
420
421
  if (annotation) {
422
+ annotation._isExport = this._isExport;
421
423
  annotation._doPostProcess(annotation.flatten || isFlatten);
422
424
  }
423
425
  }
@@ -34,6 +34,7 @@ export declare abstract class PdfAnnotation {
34
34
  _page: PdfPage;
35
35
  _isLoaded: boolean;
36
36
  _setAppearance: boolean;
37
+ _isExport: boolean;
37
38
  _color: number[];
38
39
  _annotFlags: PdfAnnotationFlag;
39
40
  _bounds: {
@@ -44,6 +44,7 @@ var PdfAnnotation = /** @class */ (function () {
44
44
  this._isImported = false;
45
45
  this._isLoaded = false;
46
46
  this._setAppearance = false;
47
+ this._isExport = false;
47
48
  this._opacity = 1;
48
49
  this._isAllRotation = true;
49
50
  this._flatten = false;
@@ -9663,11 +9664,11 @@ var PdfRubberStampAnnotation = /** @class */ (function (_super) {
9663
9664
  PdfRubberStampAnnotation.prototype._doPostProcess = function (isFlatten) {
9664
9665
  if (isFlatten === void 0) { isFlatten = false; }
9665
9666
  var isTransformBBox = false;
9666
- if (this._isLoaded && (this._setAppearance || isFlatten)) {
9667
- if (!isFlatten) {
9667
+ if (this._isLoaded && (this._setAppearance || isFlatten || this._isExport)) {
9668
+ if ((!isFlatten && !this._isExport) || this._setAppearance) {
9668
9669
  this._appearanceTemplate = this._createRubberStampAppearance();
9669
9670
  }
9670
- if (!this._appearanceTemplate && isFlatten && this._dictionary.has('AP')) {
9671
+ if (!this._appearanceTemplate && (this._isExport || isFlatten) && this._dictionary.has('AP')) {
9671
9672
  var dictionary = this._dictionary.get('AP');
9672
9673
  if (dictionary && dictionary.has('N')) {
9673
9674
  var appearanceStream = dictionary.get('N');
@@ -9724,8 +9725,10 @@ var PdfRubberStampAnnotation = /** @class */ (function (_super) {
9724
9725
  }
9725
9726
  }
9726
9727
  else {
9727
- this._postProcess();
9728
- if ((!this._appearanceTemplate) && isFlatten) {
9728
+ if (!(this._isImported && this._dictionary.has('AP'))) {
9729
+ this._postProcess();
9730
+ }
9731
+ if ((!this._appearanceTemplate) && (isFlatten || this._isImported)) {
9729
9732
  if (!this._dictionary.has('AP')) {
9730
9733
  this._appearanceTemplate = this._createRubberStampAppearance();
9731
9734
  }
@@ -472,6 +472,7 @@ var _JsonDocument = /** @class */ (function (_super) {
472
472
  case 'MeasurementTypes':
473
473
  case 'GroupNesting':
474
474
  case 'ITEx':
475
+ case 'TextMarkupContent':
475
476
  break;
476
477
  case 'Border':
477
478
  case 'A':
@@ -16,7 +16,7 @@ import { PdfAnnotation, PdfFileLinkAnnotation, PdfTextWebLinkAnnotation, PdfDocu
16
16
  import { PdfAnnotationFlag } from './../enumerator';
17
17
  import { _PdfDictionary, _PdfName, _PdfReference } from './../pdf-primitives';
18
18
  import { _PdfBaseStream, _PdfContentStream } from './../base-stream';
19
- import { _hexStringToByteArray, _stringToAnnotationFlags, _convertToColor, _bytesToString, _hexStringToString, _getSpecialCharacter, _getLatinCharacter, _getInheritableProperty, _getNewGuidString, _byteArrayToHexString, _stringToBytes, _annotationFlagsToString, _encode, _decode } from './../utils';
19
+ import { _hexStringToByteArray, _stringToAnnotationFlags, _convertToColor, _bytesToString, _hexStringToString, _getSpecialCharacter, _getLatinCharacter, _getInheritableProperty, _getNewGuidString, _byteArrayToHexString, _stringToBytes, _annotationFlagsToString, _encode } from './../utils';
20
20
  import { PdfCheckBoxField, PdfComboBoxField, PdfListBoxField, PdfRadioButtonListField, PdfTextBoxField, PdfListField } from './../form/field';
21
21
  var _ExportHelper = /** @class */ (function () {
22
22
  function _ExportHelper() {
@@ -1303,7 +1303,7 @@ var _XfdfDocument = /** @class */ (function (_super) {
1303
1303
  }
1304
1304
  };
1305
1305
  _XfdfDocument.prototype._writeObject = function (writer, primitive, dictionary, key) {
1306
- if (primitive) {
1306
+ if (primitive !== null && typeof primitive !== 'undefined') {
1307
1307
  if (primitive instanceof _PdfName) {
1308
1308
  this._writePrefix(writer, 'NAME', key);
1309
1309
  writer._writeAttributeString('VAL', primitive.name);
@@ -1530,6 +1530,7 @@ var _XfdfDocument = /** @class */ (function (_super) {
1530
1530
  case 'Vertices':
1531
1531
  case 'GroupNesting':
1532
1532
  case 'ITEx':
1533
+ case 'TextMarkupContent':
1533
1534
  break;
1534
1535
  default:
1535
1536
  this._writeAttributeString(writer, key.toLowerCase(), primitive);
@@ -1847,6 +1848,7 @@ var _XfdfDocument = /** @class */ (function (_super) {
1847
1848
  var annotations = page.annotations;
1848
1849
  var annotation = annotations._parseAnnotation(annotationDictionary);
1849
1850
  if (annotation) {
1851
+ annotation._isImported = true;
1850
1852
  var reference = this._crossReference._getNextReference();
1851
1853
  this._crossReference._cacheMap.set(reference, annotationDictionary);
1852
1854
  if (annotationDictionary.has('NM') || annotationDictionary.has('IRT')) {
@@ -2367,26 +2369,23 @@ var _XfdfDocument = /** @class */ (function (_super) {
2367
2369
  _XfdfDocument.prototype._addAppearanceData = function (element, dictionary) {
2368
2370
  var innerText = element.textContent;
2369
2371
  if (innerText && innerText !== '') {
2370
- var appearanceArray = _decode(innerText);
2371
- if (appearanceArray && appearanceArray.length > 0) {
2372
- var document_1 = (new DOMParser()).parseFromString(_bytesToString(appearanceArray), 'text/xml');
2373
- if (document_1 && document_1.hasChildNodes) {
2374
- var childNodes = document_1.childNodes;
2375
- if (childNodes && childNodes.length === 1) {
2376
- var rootNode = childNodes[0];
2377
- if (rootNode && rootNode.nodeType === 1) {
2378
- var rootElement = rootNode;
2379
- if (rootElement.nodeName.toLowerCase() === 'DICT' && rootElement.hasAttribute('KEY')) {
2380
- var key = rootElement.getAttribute('KEY');
2381
- if (key && key === 'AP' && rootElement.hasChildNodes) {
2382
- var appearance = new _PdfDictionary(this._crossReference);
2383
- childNodes = rootElement.childNodes;
2384
- for (var i = 0; i < childNodes.length; i++) {
2385
- this._getAppearance(appearance, childNodes[Number.parseInt(i.toString(), 10)]);
2386
- }
2387
- if (appearance.size > 0) {
2388
- dictionary.update('AP', appearance);
2389
- }
2372
+ var document_1 = (new DOMParser()).parseFromString(atob(innerText), 'text/xml');
2373
+ if (document_1 && document_1.hasChildNodes) {
2374
+ var childNodes = document_1.childNodes;
2375
+ if (childNodes && childNodes.length === 1) {
2376
+ var rootNode = childNodes[0];
2377
+ if (rootNode && rootNode.nodeType === 1) {
2378
+ var rootElement = rootNode;
2379
+ if (rootElement.nodeName.toUpperCase() === 'DICT' && rootElement.hasAttribute('KEY')) {
2380
+ var key = rootElement.getAttribute('KEY');
2381
+ if (key && key === 'AP' && rootElement.hasChildNodes) {
2382
+ var appearance = new _PdfDictionary(this._crossReference);
2383
+ childNodes = rootElement.childNodes;
2384
+ for (var i = 0; i < childNodes.length; i++) {
2385
+ this._getAppearance(appearance, childNodes[Number.parseInt(i.toString(), 10)]);
2386
+ }
2387
+ if (appearance.size > 0) {
2388
+ dictionary.update('AP', appearance);
2390
2389
  }
2391
2390
  }
2392
2391
  }
@@ -2416,7 +2415,7 @@ var _XfdfDocument = /** @class */ (function (_super) {
2416
2415
  dictionary = this._getDictionary(element);
2417
2416
  if (dictionary) {
2418
2417
  var reference = this._crossReference._getNextReference();
2419
- this._crossReference._cacheMap.set(reference, stream);
2418
+ this._crossReference._cacheMap.set(reference, dictionary);
2420
2419
  this._addKey(reference, appearance, element);
2421
2420
  }
2422
2421
  break;
@@ -45,6 +45,7 @@ export declare class PdfDocument {
45
45
  _hasUserPasswordOnly: boolean;
46
46
  _encryptOnlyAttachment: boolean;
47
47
  _encryptMetaData: boolean;
48
+ _isExport: boolean;
48
49
  private _allowCustomData;
49
50
  /**
50
51
  * Initializes a new instance of the `PdfDocument` class.
@@ -44,6 +44,7 @@ var PdfDocument = /** @class */ (function () {
44
44
  this._hasUserPasswordOnly = false;
45
45
  this._encryptOnlyAttachment = false;
46
46
  this._encryptMetaData = false;
47
+ this._isExport = false;
47
48
  this._allowCustomData = false;
48
49
  if (!data) {
49
50
  throw new Error('PDF data cannot be undefined or null');
@@ -418,6 +419,7 @@ var PdfDocument = /** @class */ (function () {
418
419
  });
419
420
  };
420
421
  PdfDocument.prototype.exportAnnotations = function (arg1, arg2) {
422
+ this._isExport = true;
421
423
  this._doPostProcessOnAnnotations();
422
424
  var helper;
423
425
  var settings;
@@ -693,6 +695,7 @@ var PdfDocument = /** @class */ (function () {
693
695
  if (isFlatten === void 0) { isFlatten = false; }
694
696
  for (var i = 0; i < this.pageCount; i++) {
695
697
  var page = this.getPage(i);
698
+ page.annotations._isExport = this._isExport;
696
699
  page.annotations._doPostProcess(isFlatten);
697
700
  if (isFlatten) {
698
701
  if (page._pageDictionary.has('Annots')) {
@@ -99,21 +99,21 @@ var _PdfEncryptor = /** @class */ (function () {
99
99
  else {
100
100
  algorithm_1 = new _BasicEncryption();
101
101
  }
102
- var password_1;
102
+ var p = void 0;
103
103
  if (passwordBytes) {
104
- password_1 = passwordBytes.subarray(0, Math.min(127, passwordBytes.length));
104
+ p = passwordBytes.subarray(0, Math.min(127, passwordBytes.length));
105
105
  }
106
106
  else {
107
- password_1 = new Uint8Array([]);
107
+ p = new Uint8Array([]);
108
108
  }
109
- if (algorithm_1._checkUserPassword(password_1, userValidationSalt, userPassword)) {
110
- encryptionKey = this._createEncryptionKey(true, password_1, ownerKeySalt, uBytes, userKeySalt, ownerEncryption, userEncryption, algorithm_1);
109
+ if (algorithm_1._checkUserPassword(p, userValidationSalt, userPassword)) {
110
+ encryptionKey = this._createEncryptionKey(true, p, ownerKeySalt, uBytes, userKeySalt, ownerEncryption, userEncryption, algorithm_1);
111
111
  this._isUserPassword = true;
112
- if (password_1.length && algorithm_1._checkOwnerPassword(password_1, ownerValidationSalt, uBytes, ownerPassword)) {
112
+ if (password.length && algorithm_1._checkOwnerPassword(p, ownerValidationSalt, uBytes, ownerPassword)) {
113
113
  this._hasUserPasswordOnly = true;
114
114
  }
115
115
  }
116
- else if (password_1.length && algorithm_1._checkOwnerPassword(password_1, ownerValidationSalt, uBytes, ownerPassword)) {
116
+ else if (password.length && algorithm_1._checkOwnerPassword(p, ownerValidationSalt, uBytes, ownerPassword)) {
117
117
  encryptionKey = this._createEncryptionKey(false, passwordBytes, ownerKeySalt, uBytes, userKeySalt, ownerEncryption, userEncryption, algorithm_1);
118
118
  this._isUserPassword = false;
119
119
  }
@@ -128,7 +128,6 @@ var _PdfEncryptor = /** @class */ (function () {
128
128
  throw new Error('Cannot open an encrypted document. The password is invalid.');
129
129
  }
130
130
  }
131
- this._encryptionKey = encryptionKey;
132
131
  if (algorithm >= 4) {
133
132
  var cipherDictionary = dictionary.get('CF');
134
133
  if (cipherDictionary) {
@@ -148,6 +147,10 @@ var _PdfEncryptor = /** @class */ (function () {
148
147
  this._string = dictionary.get('StrF') || _PdfName.get('Identity');
149
148
  this._eff = dictionary.get('EFF') || this._stream;
150
149
  }
150
+ if (!encryptionKey && !this._encryptOnlyAttachment) {
151
+ throw new Error('Cannot open an encrypted document. The password is invalid.');
152
+ }
153
+ this._encryptionKey = encryptionKey;
151
154
  }
152
155
  Object.defineProperty(_PdfEncryptor.prototype, "_md5", {
153
156
  get: function () {
@@ -1552,7 +1555,7 @@ var _AdvancedEncryption256Cipher = /** @class */ (function (_super) {
1552
1555
  }
1553
1556
  }
1554
1557
  for (var n = 0; n < 4; ++n) {
1555
- result[Number.parseInt(i.toString(), 10)] = t1 ^= result[j - 32];
1558
+ result[Number.parseInt(j.toString(), 10)] = t1 ^= result[j - 32];
1556
1559
  result[j + 1] = t2 ^= result[j - 31];
1557
1560
  result[j + 2] = t3 ^= result[j - 30];
1558
1561
  result[j + 3] = t4 ^= result[j - 29];