@syncfusion/ej2-pdf 25.1.39 → 25.1.41
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 +90 -23
- package/dist/es6/ej2-pdf.es2015.js.map +1 -1
- package/dist/es6/ej2-pdf.es5.js +91 -23
- 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 +5 -5
- package/src/pdf/core/form/form.js +0 -1
- package/src/pdf/core/import-export/json-document.d.ts +1 -0
- package/src/pdf/core/import-export/json-document.js +27 -1
- package/src/pdf/core/pdf-catalog.js +2 -0
- package/src/pdf/core/pdf-cross-reference.js +10 -8
- package/src/pdf/core/pdf-document.js +14 -12
- package/src/pdf/core/pdf-page.js +4 -1
- package/src/pdf/core/utils.d.ts +7 -0
- package/src/pdf/core/utils.js +34 -0
package/dist/global/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* filename: index.d.ts
|
|
3
|
-
* version : 25.1.
|
|
3
|
+
* version : 25.1.41
|
|
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@25.1.
|
|
3
|
+
"_id": "@syncfusion/ej2-pdf@25.1.40",
|
|
4
4
|
"_inBundle": false,
|
|
5
|
-
"_integrity": "sha512-
|
|
5
|
+
"_integrity": "sha512-pBiQSd8rMc6N9jXuEse841ZfDh5gOANZFNGhT2im35bSEJ1Sg7+6HAvcuTUUEjU6v92Xm9oVgZpbOKyWC+d7Ug==",
|
|
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.syncfusioninternal.com/repository/ej2-hotfix-new/@syncfusion/ej2-pdf/-/ej2-pdf-25.1.
|
|
25
|
-
"_shasum": "
|
|
24
|
+
"_resolved": "https://nexus.syncfusioninternal.com/repository/ej2-hotfix-new/@syncfusion/ej2-pdf/-/ej2-pdf-25.1.40.tgz",
|
|
25
|
+
"_shasum": "d62d8fd1ff43ad30c2db1da539000197f57715f0",
|
|
26
26
|
"_spec": "@syncfusion/ej2-pdf@*",
|
|
27
27
|
"_where": "/jenkins/workspace/elease-automation_release_25.1.1/packages/included",
|
|
28
28
|
"author": {
|
|
@@ -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": "25.1.
|
|
58
|
+
"version": "25.1.41",
|
|
59
59
|
"sideEffects": false,
|
|
60
60
|
"homepage": "https://www.syncfusion.com/javascript-ui-controls"
|
|
61
61
|
}
|
|
@@ -239,7 +239,6 @@ var PdfForm = /** @class */ (function () {
|
|
|
239
239
|
this._dictionary.update('Fields', this._fields);
|
|
240
240
|
this._parsedFields.set(this._fields.length - 1, field);
|
|
241
241
|
field._form = this;
|
|
242
|
-
this._crossReference._allowCatalog = true;
|
|
243
242
|
this._crossReference._root._updated = true;
|
|
244
243
|
if (field._kidsCount > 0) {
|
|
245
244
|
for (var i = 0; i < field._kidsCount; i++) {
|
|
@@ -5,6 +5,7 @@ import { _PdfDictionary } from './../pdf-primitives';
|
|
|
5
5
|
import { _PdfContentStream } from './../base-stream';
|
|
6
6
|
export declare class _JsonDocument extends _ExportHelper {
|
|
7
7
|
_isImport: boolean;
|
|
8
|
+
_isColorSpace: boolean;
|
|
8
9
|
constructor(fileName?: string);
|
|
9
10
|
_exportAnnotations(document: PdfDocument): Uint8Array;
|
|
10
11
|
_exportFormFields(document: PdfDocument): Uint8Array;
|
|
@@ -21,6 +21,7 @@ var _JsonDocument = /** @class */ (function (_super) {
|
|
|
21
21
|
function _JsonDocument(fileName) {
|
|
22
22
|
var _this = _super.call(this) || this;
|
|
23
23
|
_this._isImport = false;
|
|
24
|
+
_this._isColorSpace = false;
|
|
24
25
|
if (fileName !== null && typeof fileName !== 'undefined') {
|
|
25
26
|
_this._fileName = fileName;
|
|
26
27
|
}
|
|
@@ -606,16 +607,31 @@ var _JsonDocument = /** @class */ (function (_super) {
|
|
|
606
607
|
}
|
|
607
608
|
};
|
|
608
609
|
_JsonDocument.prototype._writeObject = function (table, value, dictionary, key, array) {
|
|
610
|
+
var _this = this;
|
|
609
611
|
if (value instanceof _PdfName) {
|
|
610
612
|
this._writeTable('name', value.name, table, key, array);
|
|
611
613
|
}
|
|
612
614
|
else if (Array.isArray(value)) {
|
|
613
615
|
var list = [];
|
|
616
|
+
if (key === 'ColorSpace') {
|
|
617
|
+
value.forEach(function (element) {
|
|
618
|
+
if (typeof element === 'string') {
|
|
619
|
+
_this._isColorSpace = true;
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
}
|
|
614
623
|
this._writeArray(list, value, dictionary);
|
|
624
|
+
this._isColorSpace = false;
|
|
615
625
|
this._writeTable('array', this._convertToJsonArray(list), table, key, array);
|
|
616
626
|
}
|
|
617
627
|
else if (typeof value === 'string') {
|
|
618
|
-
this.
|
|
628
|
+
if (this._isColorSpace) {
|
|
629
|
+
var bytes = _stringToBytes(value);
|
|
630
|
+
this._writeTable('unicodeData', _byteArrayToHexString(bytes), table, key, array);
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
this._writeTable('string', value, table, key, array);
|
|
634
|
+
}
|
|
619
635
|
}
|
|
620
636
|
else if (typeof value === 'number') {
|
|
621
637
|
this._writeTable(Number.isInteger(value) ? 'int' : 'fixed', value.toString(), table, key, array);
|
|
@@ -642,6 +658,13 @@ var _JsonDocument = /** @class */ (function (_super) {
|
|
|
642
658
|
var stream = baseStream.stream;
|
|
643
659
|
data = baseStream.getString(true, stream.getByteRange(stream.start, stream.end));
|
|
644
660
|
}
|
|
661
|
+
else if (baseStream.stream && baseStream.stream.stream) {
|
|
662
|
+
var flateStream = baseStream.stream; // eslint-disable-line
|
|
663
|
+
if (flateStream.stream && flateStream.stream instanceof _PdfStream) {
|
|
664
|
+
var stream = flateStream.stream;
|
|
665
|
+
data = flateStream.getString(true, stream.getByteRange(stream.start, stream.end));
|
|
666
|
+
}
|
|
667
|
+
}
|
|
645
668
|
else {
|
|
646
669
|
data = value.getString(true);
|
|
647
670
|
}
|
|
@@ -1486,6 +1509,9 @@ var _JsonDocument = /** @class */ (function (_super) {
|
|
|
1486
1509
|
stream.dictionary.objId = value.objectNumber + ' ' + value.generationNumber;
|
|
1487
1510
|
this._crossReference._cacheMap.set(value, stream);
|
|
1488
1511
|
}
|
|
1512
|
+
else if (keys.indexOf('unicodeData') !== -1) {
|
|
1513
|
+
value = _bytesToString(_hexStringToByteArray(element.unicodeData, true));
|
|
1514
|
+
}
|
|
1489
1515
|
else {
|
|
1490
1516
|
value = null;
|
|
1491
1517
|
}
|
|
@@ -60,6 +60,8 @@ var _PdfCatalog = /** @class */ (function () {
|
|
|
60
60
|
this._crossReference._cacheMap.set(ref, form);
|
|
61
61
|
this._catalogDictionary.set('AcroForm', ref);
|
|
62
62
|
this._catalogDictionary._updated = true;
|
|
63
|
+
this._crossReference._allowCatalog = true;
|
|
64
|
+
form._updated = true;
|
|
63
65
|
return form;
|
|
64
66
|
};
|
|
65
67
|
_PdfCatalog.prototype.getPageDictionary = function (pageIndex) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _PdfStream } from './base-stream';
|
|
2
2
|
import { _PdfDictionary, _PdfReferenceSet, _isCommand, _PdfReference, _PdfName } from './pdf-primitives';
|
|
3
|
-
import { BaseException, FormatError, _escapePdfName, _bytesToString, ParserEndOfFileException, _numberToString, _stringToPdfString } from './utils';
|
|
3
|
+
import { BaseException, FormatError, _escapePdfName, _bytesToString, ParserEndOfFileException, _numberToString, _stringToPdfString, _getSize } from './utils';
|
|
4
4
|
import { _PdfParser, _PdfLexicalOperator } from './pdf-parser';
|
|
5
5
|
import { _PdfBaseStream } from './base-stream';
|
|
6
6
|
import { PdfCrossReferenceType } from './enumerator';
|
|
@@ -742,39 +742,40 @@ var _PdfCrossReference = /** @class */ (function () {
|
|
|
742
742
|
}
|
|
743
743
|
this._writeObject(archiveStream, buffer, archiveRef, cipher_2);
|
|
744
744
|
}
|
|
745
|
+
var formatValue = Math.max(_getSize(this._stream.bytes.length + buffer.length), _getSize(this._nextReferenceNumber));
|
|
745
746
|
var newRef = this._getNextReference();
|
|
746
747
|
var newStartXref = currentLength + buffer.length;
|
|
747
748
|
var newXref = new _PdfDictionary(this);
|
|
748
749
|
newXref.set('Type', _PdfName.get('XRef'));
|
|
749
750
|
newXref.set('Index', indexes_1);
|
|
750
|
-
newXref.set('W', [1,
|
|
751
|
+
newXref.set('W', [1, formatValue, 1]);
|
|
751
752
|
this._copyTrailer(newXref);
|
|
752
753
|
if (this._ids && this._ids.length > 0) {
|
|
753
754
|
newXref.update('ID', [this._ids[0], this._computeMessageDigest(newStartXref)]);
|
|
754
755
|
}
|
|
755
756
|
var newXrefData = [];
|
|
756
757
|
this._writeLong(0, 1, newXrefData);
|
|
757
|
-
this._writeLong(1,
|
|
758
|
+
this._writeLong(1, formatValue, newXrefData);
|
|
758
759
|
this._writeLong(-1, 1, newXrefData);
|
|
759
760
|
if (uncompressedCount > 0) {
|
|
760
761
|
for (var index = 0; index < uncompressedCount; index++) {
|
|
761
762
|
this._writeLong(1, 1, newXrefData);
|
|
762
|
-
this._writeLong(uncompressedOffsets_1[index],
|
|
763
|
+
this._writeLong(uncompressedOffsets_1[index], formatValue, newXrefData); // eslint-disable-line
|
|
763
764
|
this._writeLong(0, 1, newXrefData);
|
|
764
765
|
}
|
|
765
766
|
}
|
|
766
767
|
if (updatedCount > 0) {
|
|
767
768
|
for (var index = 0; index < updatedCount; index++) {
|
|
768
769
|
this._writeLong(2, 1, newXrefData);
|
|
769
|
-
this._writeLong(archiveRef.objectNumber,
|
|
770
|
+
this._writeLong(archiveRef.objectNumber, formatValue, newXrefData);
|
|
770
771
|
this._writeLong(index, 1, newXrefData);
|
|
771
772
|
}
|
|
772
773
|
this._writeLong(1, 1, newXrefData);
|
|
773
|
-
this._writeLong(archiveOffset,
|
|
774
|
+
this._writeLong(archiveOffset, formatValue, newXrefData);
|
|
774
775
|
this._writeLong(0, 1, newXrefData);
|
|
775
776
|
}
|
|
776
777
|
this._writeLong(1, 1, newXrefData);
|
|
777
|
-
this._writeLong(newStartXref,
|
|
778
|
+
this._writeLong(newStartXref, formatValue, newXrefData);
|
|
778
779
|
this._writeLong(0, 1, newXrefData);
|
|
779
780
|
newXref.set('Length', newXrefData.length);
|
|
780
781
|
var newXrefStream = new _PdfStream(newXrefData, newXref, 0, newXrefData.length);
|
|
@@ -826,7 +827,8 @@ var _PdfCrossReference = /** @class */ (function () {
|
|
|
826
827
|
return array;
|
|
827
828
|
};
|
|
828
829
|
_PdfCrossReference.prototype._copyTrailer = function (newXref) {
|
|
829
|
-
|
|
830
|
+
var reference = this._getNextReference();
|
|
831
|
+
newXref.set('Size', reference.objectNumber);
|
|
830
832
|
newXref.set('Prev', this._prevXRefOffset);
|
|
831
833
|
var root = this._trailer.getRaw('Root'); // eslint-disable-line
|
|
832
834
|
if (typeof root !== 'undefined' && root !== null) {
|
|
@@ -1110,19 +1110,21 @@ var PdfDocument = /** @class */ (function () {
|
|
|
1110
1110
|
};
|
|
1111
1111
|
PdfDocument.prototype._doPostProcessOnFormFields = function (isFlatten) {
|
|
1112
1112
|
if (isFlatten === void 0) { isFlatten = false; }
|
|
1113
|
-
this.
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1113
|
+
if (this._catalog._catalogDictionary.has('AcroForm')) {
|
|
1114
|
+
this.form._doPostProcess(isFlatten);
|
|
1115
|
+
if (isFlatten) {
|
|
1116
|
+
var formObject = this._catalog._catalogDictionary.getRaw('AcroForm');
|
|
1117
|
+
var dictionary = new _PdfDictionary(this._crossReference);
|
|
1118
|
+
dictionary._updated = true;
|
|
1119
|
+
if (formObject instanceof _PdfReference) {
|
|
1120
|
+
this._crossReference._cacheMap.set(formObject, dictionary);
|
|
1121
|
+
}
|
|
1122
|
+
else {
|
|
1123
|
+
this.form._dictionary = dictionary;
|
|
1124
|
+
this._crossReference._allowCatalog = true;
|
|
1125
|
+
}
|
|
1126
|
+
this.form._clear();
|
|
1124
1127
|
}
|
|
1125
|
-
this.form._clear();
|
|
1126
1128
|
}
|
|
1127
1129
|
};
|
|
1128
1130
|
PdfDocument.prototype._doPostProcessOnAnnotations = function (isFlatten) {
|
package/src/pdf/core/pdf-page.js
CHANGED
|
@@ -59,7 +59,10 @@ var PdfPage = /** @class */ (function () {
|
|
|
59
59
|
if (this._pageDictionary.has('Annots')) {
|
|
60
60
|
var annots = this._getProperty('Annots');
|
|
61
61
|
if (annots && Array.isArray(annots)) {
|
|
62
|
-
var widgets_1
|
|
62
|
+
var widgets_1;
|
|
63
|
+
if (this._crossReference._document._catalog._catalogDictionary.has('AcroForm')) {
|
|
64
|
+
widgets_1 = this._crossReference._document.form._parseWidgetReferences();
|
|
65
|
+
}
|
|
63
66
|
if (widgets_1 && widgets_1.length > 0) {
|
|
64
67
|
var validAnnotations_1 = [];
|
|
65
68
|
annots.forEach(function (entry) {
|
package/src/pdf/core/utils.d.ts
CHANGED
|
@@ -758,3 +758,10 @@ export declare function _updateBounds(annotation: PdfAnnotation, bounds?: number
|
|
|
758
758
|
* @returns {string} Decoded text.
|
|
759
759
|
*/
|
|
760
760
|
export declare function _decodeText(text: string, isColorSpace: boolean, isPassword: boolean): string;
|
|
761
|
+
/**
|
|
762
|
+
* Number of bytes required to save the number.
|
|
763
|
+
*
|
|
764
|
+
* @param {number} input number.
|
|
765
|
+
* @returns {number} number of bytes.
|
|
766
|
+
*/
|
|
767
|
+
export declare function _getSize(input: number): number;
|
package/src/pdf/core/utils.js
CHANGED
|
@@ -3957,3 +3957,37 @@ export function _decodeText(text, isColorSpace, isPassword) {
|
|
|
3957
3957
|
}
|
|
3958
3958
|
return text;
|
|
3959
3959
|
}
|
|
3960
|
+
/**
|
|
3961
|
+
* Number of bytes required to save the number.
|
|
3962
|
+
*
|
|
3963
|
+
* @param {number} input number.
|
|
3964
|
+
* @returns {number} number of bytes.
|
|
3965
|
+
*/
|
|
3966
|
+
export function _getSize(input) {
|
|
3967
|
+
var size = 0;
|
|
3968
|
+
var uintMaxValue = 0xFFFFFFFF;
|
|
3969
|
+
var ushortMaxValue = 0xFFFF;
|
|
3970
|
+
var byteMaxValue = 0xFF;
|
|
3971
|
+
if (input <= uintMaxValue) {
|
|
3972
|
+
if (input <= ushortMaxValue) {
|
|
3973
|
+
if (input <= byteMaxValue) {
|
|
3974
|
+
size = 1;
|
|
3975
|
+
}
|
|
3976
|
+
else {
|
|
3977
|
+
size = 2;
|
|
3978
|
+
}
|
|
3979
|
+
}
|
|
3980
|
+
else {
|
|
3981
|
+
if (input <= (ushortMaxValue | (ushortMaxValue << 8))) {
|
|
3982
|
+
size = 3;
|
|
3983
|
+
}
|
|
3984
|
+
else {
|
|
3985
|
+
size = 4;
|
|
3986
|
+
}
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
else {
|
|
3990
|
+
size = 8;
|
|
3991
|
+
}
|
|
3992
|
+
return size;
|
|
3993
|
+
}
|