@syncfusion/ej2-pdf 24.2.7 → 24.2.9
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 +157 -37
- package/dist/es6/ej2-pdf.es2015.js.map +1 -1
- package/dist/es6/ej2-pdf.es5.js +158 -38
- 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/field.d.ts +1 -0
- package/src/pdf/core/form/field.js +7 -0
- package/src/pdf/core/form/form.d.ts +5 -0
- package/src/pdf/core/form/form.js +140 -33
- package/src/pdf/core/pdf-cross-reference.js +11 -5
package/dist/global/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* filename: index.d.ts
|
|
3
|
-
* version : 24.2.
|
|
3
|
+
* version : 24.2.9
|
|
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@24.2.
|
|
3
|
+
"_id": "@syncfusion/ej2-pdf@24.2.8",
|
|
4
4
|
"_inBundle": false,
|
|
5
|
-
"_integrity": "sha512-
|
|
5
|
+
"_integrity": "sha512-sldIPEmlR0Cod7QoBhd2U/a2NviS+rMh1/tIbW3GddUkHm9+kfyVFYNbCpGdiq/FAn90MJldMsDfFf+TdkziYQ==",
|
|
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-24.2.
|
|
25
|
-
"_shasum": "
|
|
24
|
+
"_resolved": "https://nexus.syncfusioninternal.com/repository/ej2-hotfix-new/@syncfusion/ej2-pdf/-/ej2-pdf-24.2.8.tgz",
|
|
25
|
+
"_shasum": "d9cc1f127ba22c3435f75b4988880810ffe74970",
|
|
26
26
|
"_spec": "@syncfusion/ej2-pdf@*",
|
|
27
27
|
"_where": "/jenkins/workspace/elease-automation_release_24.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": "24.2.
|
|
58
|
+
"version": "24.2.9",
|
|
59
59
|
"sideEffects": false,
|
|
60
60
|
"homepage": "https://www.syncfusion.com/javascript-ui-controls"
|
|
61
61
|
}
|
|
@@ -855,6 +855,7 @@ export declare abstract class PdfField {
|
|
|
855
855
|
_getAppearanceStateValue(): string;
|
|
856
856
|
_getTextAlignment(): PdfTextAlignment;
|
|
857
857
|
_setTextAlignment(value: PdfTextAlignment): void;
|
|
858
|
+
_parseItems(): PdfWidgetAnnotation[];
|
|
858
859
|
}
|
|
859
860
|
/**
|
|
860
861
|
* `PdfTextBoxField` class represents the text box field objects.
|
|
@@ -2133,6 +2133,13 @@ var PdfField = /** @class */ (function () {
|
|
|
2133
2133
|
this._textAlignment = value;
|
|
2134
2134
|
this._stringFormat = new PdfStringFormat(value, PdfVerticalAlignment.middle);
|
|
2135
2135
|
};
|
|
2136
|
+
PdfField.prototype._parseItems = function () {
|
|
2137
|
+
var collection = [];
|
|
2138
|
+
for (var i = 0; i < this.itemsCount; i++) {
|
|
2139
|
+
collection.push(this.itemAt(i));
|
|
2140
|
+
}
|
|
2141
|
+
return collection;
|
|
2142
|
+
};
|
|
2136
2143
|
return PdfField;
|
|
2137
2144
|
}());
|
|
2138
2145
|
export { PdfField };
|
|
@@ -2,6 +2,7 @@ import { _PdfDictionary, _PdfName, _PdfReference } from './../pdf-primitives';
|
|
|
2
2
|
import { _PdfCrossReference } from './../pdf-cross-reference';
|
|
3
3
|
import { PdfField } from './field';
|
|
4
4
|
import { PdfFormFieldsTabOrder, _SignatureFlag } from './../enumerator';
|
|
5
|
+
import { PdfPage } from './../pdf-page';
|
|
5
6
|
/**
|
|
6
7
|
* Represents a PDF form.
|
|
7
8
|
* ```typescript
|
|
@@ -273,7 +274,11 @@ export declare class PdfForm {
|
|
|
273
274
|
_getOrder(tabOrder: PdfFormFieldsTabOrder): _PdfName;
|
|
274
275
|
_compareFields(field1: any, field2: any): number;
|
|
275
276
|
_getRectangle(dictionary: _PdfDictionary): number[];
|
|
277
|
+
_getItemRectangle(field: PdfField): number[];
|
|
276
278
|
_compare(x: number, y: number): number;
|
|
277
279
|
_compareKidsElement(x: _PdfReference, y: _PdfReference): number;
|
|
280
|
+
_sortItemByPageIndex(field: PdfField, hasPageTabOrder: boolean): PdfPage;
|
|
281
|
+
_sortFieldItems(field: PdfField): void;
|
|
282
|
+
_compareFieldItem(item1: any, item2: any): number;
|
|
278
283
|
_clear(): void;
|
|
279
284
|
}
|
|
@@ -377,7 +377,7 @@ var PdfForm = /** @class */ (function () {
|
|
|
377
377
|
for (var i = 0; i < this._fieldCollection.length; i++) {
|
|
378
378
|
var field = this._fieldCollection[Number.parseInt(i.toString(), 10)];
|
|
379
379
|
if (field.page) {
|
|
380
|
-
var index = _getPageIndex(document_1, field.
|
|
380
|
+
var index = _getPageIndex(document_1, this._sortItemByPageIndex(field, true)._pageDictionary);
|
|
381
381
|
if (index >= 0) {
|
|
382
382
|
if (fieldCollection.has(index)) {
|
|
383
383
|
value = fieldCollection.get(index);
|
|
@@ -401,16 +401,18 @@ var PdfForm = /** @class */ (function () {
|
|
|
401
401
|
var fieldsCount_1 = 0;
|
|
402
402
|
fieldCollection.forEach(function (value, key) {
|
|
403
403
|
_this._tabOrder = _this._tabCollection.get(key);
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
var
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
404
|
+
if (_this._tabOrder !== PdfFormFieldsTabOrder.structure) {
|
|
405
|
+
var fields = value;
|
|
406
|
+
fields.sort(function (pdfField1, pdfField2) {
|
|
407
|
+
return _this._compareFields(pdfField1, pdfField2);
|
|
408
|
+
});
|
|
409
|
+
for (var j = 0; j < fields.length; j++) {
|
|
410
|
+
var fieldIndex = _this._fieldCollection.indexOf(fields[Number.parseInt(j.toString(), 10)]);
|
|
411
|
+
if (fieldIndex !== -1 && fieldIndex !== fieldsCount_1 + j) {
|
|
412
|
+
var field = _this._fieldCollection[Number.parseInt(fieldIndex.toString(), 10)];
|
|
413
|
+
_this._fieldCollection.splice(fieldIndex, 1);
|
|
414
|
+
_this._fieldCollection.splice(fieldsCount_1 + j, 0, field);
|
|
415
|
+
}
|
|
414
416
|
}
|
|
415
417
|
}
|
|
416
418
|
fieldsCount_1 += value.length;
|
|
@@ -650,10 +652,24 @@ var PdfForm = /** @class */ (function () {
|
|
|
650
652
|
var page1 = field1.page;
|
|
651
653
|
var page2 = field2.page;
|
|
652
654
|
if (page1 && page1 instanceof PdfPage && page2 && page2 instanceof PdfPage) {
|
|
653
|
-
var page1Index =
|
|
654
|
-
var page2Index =
|
|
655
|
-
var rectangle1 =
|
|
656
|
-
|
|
655
|
+
var page1Index = this._sortItemByPageIndex(field1, false)._pageIndex;
|
|
656
|
+
var page2Index = this._sortItemByPageIndex(field2, false)._pageIndex;
|
|
657
|
+
var rectangle1 = void 0;
|
|
658
|
+
if (field1._dictionary.has('Kids')) {
|
|
659
|
+
rectangle1 = this._getItemRectangle(field1);
|
|
660
|
+
}
|
|
661
|
+
else {
|
|
662
|
+
rectangle1 = this._getRectangle(field1._dictionary);
|
|
663
|
+
}
|
|
664
|
+
var rectangle2 = void 0;
|
|
665
|
+
if (field2._dictionary.has('Kids')) {
|
|
666
|
+
rectangle2 = this._getItemRectangle(field2);
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
rectangle2 = this._getRectangle(field2._dictionary);
|
|
670
|
+
}
|
|
671
|
+
var firstHeight = rectangle1[3] - rectangle1[1];
|
|
672
|
+
var secondHeight = rectangle2[3] - rectangle2[1];
|
|
657
673
|
if (rectangle1 && rectangle1.length >= 2 && rectangle2 && rectangle2.length >= 2) {
|
|
658
674
|
var x1 = rectangle1[0];
|
|
659
675
|
var y1 = rectangle1[1];
|
|
@@ -664,6 +680,13 @@ var PdfForm = /** @class */ (function () {
|
|
|
664
680
|
index = page1Index - page2Index;
|
|
665
681
|
if (this._tabOrder === PdfFormFieldsTabOrder.row) {
|
|
666
682
|
xdiff = this._compare(y2, y1);
|
|
683
|
+
if (xdiff !== 0) {
|
|
684
|
+
var isValid = xdiff === -1 && y1 > y2 && (y1 - firstHeight / 2) < y2;
|
|
685
|
+
isValid = isValid || (xdiff === 1 && y2 > y1 && (y2 - secondHeight / 2) < y1);
|
|
686
|
+
if (isValid) {
|
|
687
|
+
xdiff = 0;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
667
690
|
if (index !== 0) {
|
|
668
691
|
result = index;
|
|
669
692
|
}
|
|
@@ -706,28 +729,32 @@ var PdfForm = /** @class */ (function () {
|
|
|
706
729
|
return result;
|
|
707
730
|
};
|
|
708
731
|
PdfForm.prototype._getRectangle = function (dictionary) {
|
|
709
|
-
var
|
|
732
|
+
var rect;
|
|
710
733
|
if (dictionary.has('Rect')) {
|
|
711
|
-
|
|
712
|
-
if (rect) {
|
|
713
|
-
return rect;
|
|
714
|
-
}
|
|
734
|
+
rect = dictionary.getArray('Rect');
|
|
715
735
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
736
|
+
return rect;
|
|
737
|
+
};
|
|
738
|
+
PdfForm.prototype._getItemRectangle = function (field) {
|
|
739
|
+
var result;
|
|
740
|
+
var dictionary = field._dictionary;
|
|
741
|
+
if (dictionary.has('Kids')) {
|
|
742
|
+
var kids = dictionary.getArray('Kids');
|
|
743
|
+
if (kids && kids.length >= 1) {
|
|
744
|
+
if (kids.length === 1) {
|
|
745
|
+
result = this._getRectangle(kids[0]);
|
|
746
|
+
}
|
|
747
|
+
else {
|
|
748
|
+
if (field && field.itemsCount > 1) {
|
|
749
|
+
result = this._getRectangle(field.itemAt(0)._dictionary);
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
result = this._getRectangle(kids[0]);
|
|
724
753
|
}
|
|
725
|
-
var dictionary_1 = this._crossReference._fetch(kidsArray[0]);
|
|
726
|
-
return this._getRectangle(dictionary_1);
|
|
727
754
|
}
|
|
728
755
|
}
|
|
729
756
|
}
|
|
730
|
-
return
|
|
757
|
+
return result;
|
|
731
758
|
};
|
|
732
759
|
PdfForm.prototype._compare = function (x, y) {
|
|
733
760
|
if (x > y) {
|
|
@@ -745,6 +772,7 @@ var PdfForm = /** @class */ (function () {
|
|
|
745
772
|
var yDictionary = this._crossReference._fetch(y);
|
|
746
773
|
var xRect = this._getRectangle(xDictionary);
|
|
747
774
|
var yRect = this._getRectangle(yDictionary);
|
|
775
|
+
var result;
|
|
748
776
|
if (xRect && xRect.length >= 2 && yRect && yRect.length >= 2) {
|
|
749
777
|
var x1 = xRect[0];
|
|
750
778
|
var y1 = xRect[1];
|
|
@@ -752,7 +780,6 @@ var PdfForm = /** @class */ (function () {
|
|
|
752
780
|
var y2 = yRect[1];
|
|
753
781
|
if (typeof x1 === 'number' && typeof x2 === 'number' &&
|
|
754
782
|
typeof y1 === 'number' && typeof y2 === 'number') {
|
|
755
|
-
var result = 0;
|
|
756
783
|
var xdiff = void 0;
|
|
757
784
|
if (this._tabOrder === PdfFormFieldsTabOrder.row) {
|
|
758
785
|
xdiff = this._compare(y2, y1);
|
|
@@ -772,10 +799,90 @@ var PdfForm = /** @class */ (function () {
|
|
|
772
799
|
result = this._compare(y2, y1);
|
|
773
800
|
}
|
|
774
801
|
}
|
|
802
|
+
else {
|
|
803
|
+
result = 0;
|
|
804
|
+
}
|
|
775
805
|
return result;
|
|
776
806
|
}
|
|
777
807
|
}
|
|
778
|
-
return
|
|
808
|
+
return result;
|
|
809
|
+
};
|
|
810
|
+
PdfForm.prototype._sortItemByPageIndex = function (field, hasPageTabOrder) {
|
|
811
|
+
var page = field.page;
|
|
812
|
+
var tabOrder = this._tabOrder;
|
|
813
|
+
this._tabOrder = hasPageTabOrder ? field.page.tabOrder : tabOrder;
|
|
814
|
+
this._sortFieldItems(field);
|
|
815
|
+
if (field._isLoaded && field._kidsCount > 1) {
|
|
816
|
+
page = field.itemAt(0).page;
|
|
817
|
+
}
|
|
818
|
+
this._tabOrder = tabOrder;
|
|
819
|
+
if (typeof page === 'undefined') {
|
|
820
|
+
page = field.page;
|
|
821
|
+
}
|
|
822
|
+
return page;
|
|
823
|
+
};
|
|
824
|
+
PdfForm.prototype._sortFieldItems = function (field) {
|
|
825
|
+
var _this = this;
|
|
826
|
+
if (field._isLoaded && (field instanceof PdfTextBoxField ||
|
|
827
|
+
field instanceof PdfListBoxField ||
|
|
828
|
+
field instanceof PdfCheckBoxField ||
|
|
829
|
+
field instanceof PdfRadioButtonListField)) {
|
|
830
|
+
var collection = field._parseItems(); // eslint-disable-line
|
|
831
|
+
collection.sort(function (item1, item2) {
|
|
832
|
+
return _this._compareFieldItem(item1, item2);
|
|
833
|
+
});
|
|
834
|
+
field._parsedItems.clear();
|
|
835
|
+
for (var i = 0; i < collection.length; i++) {
|
|
836
|
+
field._parsedItems.set(i, collection[Number.parseInt(i.toString(), 10)]);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
PdfForm.prototype._compareFieldItem = function (item1, item2) {
|
|
841
|
+
var result = 0;
|
|
842
|
+
if (typeof item1 !== 'undefined' && typeof item2 !== 'undefined') {
|
|
843
|
+
var page1 = item1.page;
|
|
844
|
+
var page2 = item2.page;
|
|
845
|
+
var array1 = this._getRectangle(item1._dictionary);
|
|
846
|
+
var array2 = this._getRectangle(item2._dictionary);
|
|
847
|
+
if (array1 && array2) {
|
|
848
|
+
var x1 = array1[0];
|
|
849
|
+
var y1 = array1[1];
|
|
850
|
+
var x2 = array2[0];
|
|
851
|
+
var y2 = array2[1];
|
|
852
|
+
var xdiff = void 0;
|
|
853
|
+
if (this._tabOrder === PdfFormFieldsTabOrder.row) {
|
|
854
|
+
xdiff = this._compare(page1._pageIndex, page2._pageIndex);
|
|
855
|
+
if (xdiff !== 0) {
|
|
856
|
+
result = xdiff;
|
|
857
|
+
}
|
|
858
|
+
else {
|
|
859
|
+
xdiff = this._compare(y2, y1);
|
|
860
|
+
if (xdiff !== 0) {
|
|
861
|
+
result = xdiff;
|
|
862
|
+
}
|
|
863
|
+
else {
|
|
864
|
+
result = this._compare(x1, x2);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
else if (this._tabOrder === PdfFormFieldsTabOrder.column) {
|
|
869
|
+
xdiff = this._compare(page1._pageIndex, page2._pageIndex);
|
|
870
|
+
if (xdiff !== 0) {
|
|
871
|
+
result = xdiff;
|
|
872
|
+
}
|
|
873
|
+
else {
|
|
874
|
+
xdiff = this._compare(x1, x2);
|
|
875
|
+
if (xdiff !== 0) {
|
|
876
|
+
result = xdiff;
|
|
877
|
+
}
|
|
878
|
+
else {
|
|
879
|
+
result = this._compare(y2, y1);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
return result;
|
|
779
886
|
};
|
|
780
887
|
PdfForm.prototype._clear = function () {
|
|
781
888
|
this._fields = [];
|
|
@@ -54,18 +54,24 @@ var _PdfCrossReference = /** @class */ (function () {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
var hasRoot = false;
|
|
57
|
+
var root;
|
|
57
58
|
try {
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
root = trailerDictionary.get('Root');
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
throw new BaseException('Invalid cross reference', 'XRefParseException');
|
|
63
|
+
}
|
|
64
|
+
if (root) {
|
|
65
|
+
try {
|
|
60
66
|
var pagesEntry = root.get('Pages');
|
|
61
67
|
if (pagesEntry) {
|
|
62
68
|
this._root = root;
|
|
63
69
|
hasRoot = true;
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
catch (ex) {
|
|
73
|
+
throw new BaseException('Invalid cross reference', 'InvalidXRef');
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
76
|
if (!hasRoot) {
|
|
71
77
|
if (!recoveryMode) {
|