@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.
- package/CHANGELOG.md +16 -0
- package/dist/ej2-pdf.umd.min.js +2 -2
- package/dist/ej2-pdf.umd.min.js.map +1 -1
- package/dist/es6/ej2-pdf.es2015.js +47 -36
- package/dist/es6/ej2-pdf.es2015.js.map +1 -1
- package/dist/es6/ej2-pdf.es5.js +47 -36
- package/dist/es6/ej2-pdf.es5.js.map +1 -1
- package/dist/global/ej2-pdf.min.js +2 -2
- package/dist/global/ej2-pdf.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +6 -6
- package/src/pdf/core/annotations/annotation-collection.d.ts +1 -0
- package/src/pdf/core/annotations/annotation-collection.js +2 -0
- package/src/pdf/core/annotations/annotation.d.ts +1 -0
- package/src/pdf/core/annotations/annotation.js +8 -5
- package/src/pdf/core/import-export/json-document.js +1 -0
- package/src/pdf/core/import-export/xfdf-document.js +22 -23
- package/src/pdf/core/pdf-document.d.ts +1 -0
- package/src/pdf/core/pdf-document.js +3 -0
- package/src/pdf/core/security/encryptor.js +12 -9
|
@@ -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.
|
|
22906
|
-
|
|
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
|
}
|
|
@@ -37461,21 +37466,21 @@ class _PdfEncryptor {
|
|
|
37461
37466
|
else {
|
|
37462
37467
|
algorithm = new _BasicEncryption();
|
|
37463
37468
|
}
|
|
37464
|
-
let
|
|
37469
|
+
let p;
|
|
37465
37470
|
if (passwordBytes) {
|
|
37466
|
-
|
|
37471
|
+
p = passwordBytes.subarray(0, Math.min(127, passwordBytes.length));
|
|
37467
37472
|
}
|
|
37468
37473
|
else {
|
|
37469
|
-
|
|
37474
|
+
p = new Uint8Array([]);
|
|
37470
37475
|
}
|
|
37471
|
-
if (algorithm._checkUserPassword(
|
|
37472
|
-
encryptionKey = this._createEncryptionKey(true,
|
|
37476
|
+
if (algorithm._checkUserPassword(p, userValidationSalt, userPassword)) {
|
|
37477
|
+
encryptionKey = this._createEncryptionKey(true, p, ownerKeySalt, uBytes, userKeySalt, ownerEncryption, userEncryption, algorithm);
|
|
37473
37478
|
this._isUserPassword = true;
|
|
37474
|
-
if (password.length && algorithm._checkOwnerPassword(
|
|
37479
|
+
if (password.length && algorithm._checkOwnerPassword(p, ownerValidationSalt, uBytes, ownerPassword)) {
|
|
37475
37480
|
this._hasUserPasswordOnly = true;
|
|
37476
37481
|
}
|
|
37477
37482
|
}
|
|
37478
|
-
else if (password.length && algorithm._checkOwnerPassword(
|
|
37483
|
+
else if (password.length && algorithm._checkOwnerPassword(p, ownerValidationSalt, uBytes, ownerPassword)) {
|
|
37479
37484
|
encryptionKey = this._createEncryptionKey(false, passwordBytes, ownerKeySalt, uBytes, userKeySalt, ownerEncryption, userEncryption, algorithm);
|
|
37480
37485
|
this._isUserPassword = false;
|
|
37481
37486
|
}
|
|
@@ -37490,7 +37495,6 @@ class _PdfEncryptor {
|
|
|
37490
37495
|
throw new Error('Cannot open an encrypted document. The password is invalid.');
|
|
37491
37496
|
}
|
|
37492
37497
|
}
|
|
37493
|
-
this._encryptionKey = encryptionKey;
|
|
37494
37498
|
if (algorithm >= 4) {
|
|
37495
37499
|
const cipherDictionary = dictionary.get('CF');
|
|
37496
37500
|
if (cipherDictionary) {
|
|
@@ -37510,6 +37514,10 @@ class _PdfEncryptor {
|
|
|
37510
37514
|
this._string = dictionary.get('StrF') || _PdfName.get('Identity');
|
|
37511
37515
|
this._eff = dictionary.get('EFF') || this._stream;
|
|
37512
37516
|
}
|
|
37517
|
+
if (!encryptionKey && !this._encryptOnlyAttachment) {
|
|
37518
|
+
throw new Error('Cannot open an encrypted document. The password is invalid.');
|
|
37519
|
+
}
|
|
37520
|
+
this._encryptionKey = encryptionKey;
|
|
37513
37521
|
}
|
|
37514
37522
|
get _md5() {
|
|
37515
37523
|
if (typeof this._messageDigest === 'undefined') {
|
|
@@ -38850,7 +38858,7 @@ class _AdvancedEncryption256Cipher extends _AdvancedEncryptionBaseCipher {
|
|
|
38850
38858
|
}
|
|
38851
38859
|
}
|
|
38852
38860
|
for (let n = 0; n < 4; ++n) {
|
|
38853
|
-
result[Number.parseInt(
|
|
38861
|
+
result[Number.parseInt(j.toString(), 10)] = t1 ^= result[j - 32];
|
|
38854
38862
|
result[j + 1] = t2 ^= result[j - 31];
|
|
38855
38863
|
result[j + 2] = t3 ^= result[j - 30];
|
|
38856
38864
|
result[j + 3] = t4 ^= result[j - 29];
|
|
@@ -42433,7 +42441,7 @@ class _XfdfDocument extends _ExportHelper {
|
|
|
42433
42441
|
}
|
|
42434
42442
|
}
|
|
42435
42443
|
_writeObject(writer, primitive, dictionary, key) {
|
|
42436
|
-
if (primitive) {
|
|
42444
|
+
if (primitive !== null && typeof primitive !== 'undefined') {
|
|
42437
42445
|
if (primitive instanceof _PdfName) {
|
|
42438
42446
|
this._writePrefix(writer, 'NAME', key);
|
|
42439
42447
|
writer._writeAttributeString('VAL', primitive.name);
|
|
@@ -42658,6 +42666,7 @@ class _XfdfDocument extends _ExportHelper {
|
|
|
42658
42666
|
case 'Vertices':
|
|
42659
42667
|
case 'GroupNesting':
|
|
42660
42668
|
case 'ITEx':
|
|
42669
|
+
case 'TextMarkupContent':
|
|
42661
42670
|
break;
|
|
42662
42671
|
default:
|
|
42663
42672
|
this._writeAttributeString(writer, key.toLowerCase(), primitive);
|
|
@@ -42974,6 +42983,7 @@ class _XfdfDocument extends _ExportHelper {
|
|
|
42974
42983
|
const annotations = page.annotations;
|
|
42975
42984
|
const annotation = annotations._parseAnnotation(annotationDictionary);
|
|
42976
42985
|
if (annotation) {
|
|
42986
|
+
annotation._isImported = true;
|
|
42977
42987
|
const reference = this._crossReference._getNextReference();
|
|
42978
42988
|
this._crossReference._cacheMap.set(reference, annotationDictionary);
|
|
42979
42989
|
if (annotationDictionary.has('NM') || annotationDictionary.has('IRT')) {
|
|
@@ -43487,26 +43497,23 @@ class _XfdfDocument extends _ExportHelper {
|
|
|
43487
43497
|
_addAppearanceData(element, dictionary) {
|
|
43488
43498
|
const innerText = element.textContent;
|
|
43489
43499
|
if (innerText && innerText !== '') {
|
|
43490
|
-
const
|
|
43491
|
-
if (
|
|
43492
|
-
|
|
43493
|
-
if (
|
|
43494
|
-
|
|
43495
|
-
if (
|
|
43496
|
-
const
|
|
43497
|
-
if (
|
|
43498
|
-
const
|
|
43499
|
-
if (
|
|
43500
|
-
const
|
|
43501
|
-
|
|
43502
|
-
|
|
43503
|
-
childNodes
|
|
43504
|
-
|
|
43505
|
-
|
|
43506
|
-
|
|
43507
|
-
if (appearance.size > 0) {
|
|
43508
|
-
dictionary.update('AP', appearance);
|
|
43509
|
-
}
|
|
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);
|
|
43510
43517
|
}
|
|
43511
43518
|
}
|
|
43512
43519
|
}
|
|
@@ -43536,7 +43543,7 @@ class _XfdfDocument extends _ExportHelper {
|
|
|
43536
43543
|
dictionary = this._getDictionary(element);
|
|
43537
43544
|
if (dictionary) {
|
|
43538
43545
|
const reference = this._crossReference._getNextReference();
|
|
43539
|
-
this._crossReference._cacheMap.set(reference,
|
|
43546
|
+
this._crossReference._cacheMap.set(reference, dictionary);
|
|
43540
43547
|
this._addKey(reference, appearance, element);
|
|
43541
43548
|
}
|
|
43542
43549
|
break;
|
|
@@ -44469,6 +44476,7 @@ class _JsonDocument extends _ExportHelper {
|
|
|
44469
44476
|
case 'MeasurementTypes':
|
|
44470
44477
|
case 'GroupNesting':
|
|
44471
44478
|
case 'ITEx':
|
|
44479
|
+
case 'TextMarkupContent':
|
|
44472
44480
|
break;
|
|
44473
44481
|
case 'Border':
|
|
44474
44482
|
case 'A':
|
|
@@ -47182,6 +47190,7 @@ class PdfDocument {
|
|
|
47182
47190
|
this._hasUserPasswordOnly = false;
|
|
47183
47191
|
this._encryptOnlyAttachment = false;
|
|
47184
47192
|
this._encryptMetaData = false;
|
|
47193
|
+
this._isExport = false;
|
|
47185
47194
|
this._allowCustomData = false;
|
|
47186
47195
|
if (!data) {
|
|
47187
47196
|
throw new Error('PDF data cannot be undefined or null');
|
|
@@ -47511,6 +47520,7 @@ class PdfDocument {
|
|
|
47511
47520
|
});
|
|
47512
47521
|
}
|
|
47513
47522
|
exportAnnotations(arg1, arg2) {
|
|
47523
|
+
this._isExport = true;
|
|
47514
47524
|
this._doPostProcessOnAnnotations();
|
|
47515
47525
|
let helper;
|
|
47516
47526
|
let settings;
|
|
@@ -47777,6 +47787,7 @@ class PdfDocument {
|
|
|
47777
47787
|
_doPostProcessOnAnnotations(isFlatten = false) {
|
|
47778
47788
|
for (let i = 0; i < this.pageCount; i++) {
|
|
47779
47789
|
const page = this.getPage(i);
|
|
47790
|
+
page.annotations._isExport = this._isExport;
|
|
47780
47791
|
page.annotations._doPostProcess(isFlatten);
|
|
47781
47792
|
if (isFlatten) {
|
|
47782
47793
|
if (page._pageDictionary.has('Annots')) {
|