@syncfusion/ej2-pdf 24.2.8 → 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 +8 -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 +146 -32
- package/dist/es6/ej2-pdf.es2015.js.map +1 -1
- package/dist/es6/ej2-pdf.es5.js +147 -33
- 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
|
@@ -8906,6 +8906,13 @@ class PdfField {
|
|
|
8906
8906
|
this._textAlignment = value;
|
|
8907
8907
|
this._stringFormat = new PdfStringFormat(value, PdfVerticalAlignment.middle);
|
|
8908
8908
|
}
|
|
8909
|
+
_parseItems() {
|
|
8910
|
+
const collection = [];
|
|
8911
|
+
for (let i = 0; i < this.itemsCount; i++) {
|
|
8912
|
+
collection.push(this.itemAt(i));
|
|
8913
|
+
}
|
|
8914
|
+
return collection;
|
|
8915
|
+
}
|
|
8909
8916
|
}
|
|
8910
8917
|
/**
|
|
8911
8918
|
* `PdfTextBoxField` class represents the text box field objects.
|
|
@@ -40702,7 +40709,7 @@ class PdfForm {
|
|
|
40702
40709
|
for (let i = 0; i < this._fieldCollection.length; i++) {
|
|
40703
40710
|
const field = this._fieldCollection[Number.parseInt(i.toString(), 10)];
|
|
40704
40711
|
if (field.page) {
|
|
40705
|
-
const index = _getPageIndex(document, field.
|
|
40712
|
+
const index = _getPageIndex(document, this._sortItemByPageIndex(field, true)._pageDictionary);
|
|
40706
40713
|
if (index >= 0) {
|
|
40707
40714
|
if (fieldCollection.has(index)) {
|
|
40708
40715
|
value = fieldCollection.get(index);
|
|
@@ -40726,16 +40733,18 @@ class PdfForm {
|
|
|
40726
40733
|
let fieldsCount = 0;
|
|
40727
40734
|
fieldCollection.forEach((value, key) => {
|
|
40728
40735
|
this._tabOrder = this._tabCollection.get(key);
|
|
40729
|
-
|
|
40730
|
-
|
|
40731
|
-
|
|
40732
|
-
|
|
40733
|
-
|
|
40734
|
-
|
|
40735
|
-
|
|
40736
|
-
|
|
40737
|
-
|
|
40738
|
-
|
|
40736
|
+
if (this._tabOrder !== PdfFormFieldsTabOrder.structure) {
|
|
40737
|
+
const fields = value;
|
|
40738
|
+
fields.sort((pdfField1, pdfField2) => {
|
|
40739
|
+
return this._compareFields(pdfField1, pdfField2);
|
|
40740
|
+
});
|
|
40741
|
+
for (let j = 0; j < fields.length; j++) {
|
|
40742
|
+
const fieldIndex = this._fieldCollection.indexOf(fields[Number.parseInt(j.toString(), 10)]);
|
|
40743
|
+
if (fieldIndex !== -1 && fieldIndex !== fieldsCount + j) {
|
|
40744
|
+
const field = this._fieldCollection[Number.parseInt(fieldIndex.toString(), 10)];
|
|
40745
|
+
this._fieldCollection.splice(fieldIndex, 1);
|
|
40746
|
+
this._fieldCollection.splice(fieldsCount + j, 0, field);
|
|
40747
|
+
}
|
|
40739
40748
|
}
|
|
40740
40749
|
}
|
|
40741
40750
|
fieldsCount += value.length;
|
|
@@ -40974,10 +40983,24 @@ class PdfForm {
|
|
|
40974
40983
|
const page1 = field1.page;
|
|
40975
40984
|
const page2 = field2.page;
|
|
40976
40985
|
if (page1 && page1 instanceof PdfPage && page2 && page2 instanceof PdfPage) {
|
|
40977
|
-
const page1Index =
|
|
40978
|
-
const page2Index =
|
|
40979
|
-
|
|
40980
|
-
|
|
40986
|
+
const page1Index = this._sortItemByPageIndex(field1, false)._pageIndex;
|
|
40987
|
+
const page2Index = this._sortItemByPageIndex(field2, false)._pageIndex;
|
|
40988
|
+
let rectangle1;
|
|
40989
|
+
if (field1._dictionary.has('Kids')) {
|
|
40990
|
+
rectangle1 = this._getItemRectangle(field1);
|
|
40991
|
+
}
|
|
40992
|
+
else {
|
|
40993
|
+
rectangle1 = this._getRectangle(field1._dictionary);
|
|
40994
|
+
}
|
|
40995
|
+
let rectangle2;
|
|
40996
|
+
if (field2._dictionary.has('Kids')) {
|
|
40997
|
+
rectangle2 = this._getItemRectangle(field2);
|
|
40998
|
+
}
|
|
40999
|
+
else {
|
|
41000
|
+
rectangle2 = this._getRectangle(field2._dictionary);
|
|
41001
|
+
}
|
|
41002
|
+
const firstHeight = rectangle1[3] - rectangle1[1];
|
|
41003
|
+
const secondHeight = rectangle2[3] - rectangle2[1];
|
|
40981
41004
|
if (rectangle1 && rectangle1.length >= 2 && rectangle2 && rectangle2.length >= 2) {
|
|
40982
41005
|
const x1 = rectangle1[0];
|
|
40983
41006
|
const y1 = rectangle1[1];
|
|
@@ -40988,6 +41011,13 @@ class PdfForm {
|
|
|
40988
41011
|
index = page1Index - page2Index;
|
|
40989
41012
|
if (this._tabOrder === PdfFormFieldsTabOrder.row) {
|
|
40990
41013
|
xdiff = this._compare(y2, y1);
|
|
41014
|
+
if (xdiff !== 0) {
|
|
41015
|
+
let isValid = xdiff === -1 && y1 > y2 && (y1 - firstHeight / 2) < y2;
|
|
41016
|
+
isValid = isValid || (xdiff === 1 && y2 > y1 && (y2 - secondHeight / 2) < y1);
|
|
41017
|
+
if (isValid) {
|
|
41018
|
+
xdiff = 0;
|
|
41019
|
+
}
|
|
41020
|
+
}
|
|
40991
41021
|
if (index !== 0) {
|
|
40992
41022
|
result = index;
|
|
40993
41023
|
}
|
|
@@ -41030,27 +41060,32 @@ class PdfForm {
|
|
|
41030
41060
|
return result;
|
|
41031
41061
|
}
|
|
41032
41062
|
_getRectangle(dictionary) {
|
|
41063
|
+
let rect;
|
|
41033
41064
|
if (dictionary.has('Rect')) {
|
|
41034
|
-
|
|
41035
|
-
if (rect) {
|
|
41036
|
-
return rect;
|
|
41037
|
-
}
|
|
41065
|
+
rect = dictionary.getArray('Rect');
|
|
41038
41066
|
}
|
|
41039
|
-
|
|
41040
|
-
|
|
41041
|
-
|
|
41042
|
-
|
|
41043
|
-
|
|
41044
|
-
|
|
41045
|
-
|
|
41046
|
-
|
|
41067
|
+
return rect;
|
|
41068
|
+
}
|
|
41069
|
+
_getItemRectangle(field) {
|
|
41070
|
+
let result;
|
|
41071
|
+
const dictionary = field._dictionary;
|
|
41072
|
+
if (dictionary.has('Kids')) {
|
|
41073
|
+
const kids = dictionary.getArray('Kids');
|
|
41074
|
+
if (kids && kids.length >= 1) {
|
|
41075
|
+
if (kids.length === 1) {
|
|
41076
|
+
result = this._getRectangle(kids[0]);
|
|
41077
|
+
}
|
|
41078
|
+
else {
|
|
41079
|
+
if (field && field.itemsCount > 1) {
|
|
41080
|
+
result = this._getRectangle(field.itemAt(0)._dictionary);
|
|
41081
|
+
}
|
|
41082
|
+
else {
|
|
41083
|
+
result = this._getRectangle(kids[0]);
|
|
41047
41084
|
}
|
|
41048
|
-
const dictionary = this._crossReference._fetch(kidsArray[0]);
|
|
41049
|
-
return this._getRectangle(dictionary);
|
|
41050
41085
|
}
|
|
41051
41086
|
}
|
|
41052
41087
|
}
|
|
41053
|
-
return
|
|
41088
|
+
return result;
|
|
41054
41089
|
}
|
|
41055
41090
|
_compare(x, y) {
|
|
41056
41091
|
if (x > y) {
|
|
@@ -41068,6 +41103,7 @@ class PdfForm {
|
|
|
41068
41103
|
const yDictionary = this._crossReference._fetch(y);
|
|
41069
41104
|
const xRect = this._getRectangle(xDictionary);
|
|
41070
41105
|
const yRect = this._getRectangle(yDictionary);
|
|
41106
|
+
let result;
|
|
41071
41107
|
if (xRect && xRect.length >= 2 && yRect && yRect.length >= 2) {
|
|
41072
41108
|
const x1 = xRect[0];
|
|
41073
41109
|
const y1 = xRect[1];
|
|
@@ -41075,7 +41111,6 @@ class PdfForm {
|
|
|
41075
41111
|
const y2 = yRect[1];
|
|
41076
41112
|
if (typeof x1 === 'number' && typeof x2 === 'number' &&
|
|
41077
41113
|
typeof y1 === 'number' && typeof y2 === 'number') {
|
|
41078
|
-
let result = 0;
|
|
41079
41114
|
let xdiff;
|
|
41080
41115
|
if (this._tabOrder === PdfFormFieldsTabOrder.row) {
|
|
41081
41116
|
xdiff = this._compare(y2, y1);
|
|
@@ -41095,10 +41130,89 @@ class PdfForm {
|
|
|
41095
41130
|
result = this._compare(y2, y1);
|
|
41096
41131
|
}
|
|
41097
41132
|
}
|
|
41133
|
+
else {
|
|
41134
|
+
result = 0;
|
|
41135
|
+
}
|
|
41098
41136
|
return result;
|
|
41099
41137
|
}
|
|
41100
41138
|
}
|
|
41101
|
-
return
|
|
41139
|
+
return result;
|
|
41140
|
+
}
|
|
41141
|
+
_sortItemByPageIndex(field, hasPageTabOrder) {
|
|
41142
|
+
let page = field.page;
|
|
41143
|
+
const tabOrder = this._tabOrder;
|
|
41144
|
+
this._tabOrder = hasPageTabOrder ? field.page.tabOrder : tabOrder;
|
|
41145
|
+
this._sortFieldItems(field);
|
|
41146
|
+
if (field._isLoaded && field._kidsCount > 1) {
|
|
41147
|
+
page = field.itemAt(0).page;
|
|
41148
|
+
}
|
|
41149
|
+
this._tabOrder = tabOrder;
|
|
41150
|
+
if (typeof page === 'undefined') {
|
|
41151
|
+
page = field.page;
|
|
41152
|
+
}
|
|
41153
|
+
return page;
|
|
41154
|
+
}
|
|
41155
|
+
_sortFieldItems(field) {
|
|
41156
|
+
if (field._isLoaded && (field instanceof PdfTextBoxField ||
|
|
41157
|
+
field instanceof PdfListBoxField ||
|
|
41158
|
+
field instanceof PdfCheckBoxField ||
|
|
41159
|
+
field instanceof PdfRadioButtonListField)) {
|
|
41160
|
+
const collection = field._parseItems(); // eslint-disable-line
|
|
41161
|
+
collection.sort((item1, item2) => {
|
|
41162
|
+
return this._compareFieldItem(item1, item2);
|
|
41163
|
+
});
|
|
41164
|
+
field._parsedItems.clear();
|
|
41165
|
+
for (let i = 0; i < collection.length; i++) {
|
|
41166
|
+
field._parsedItems.set(i, collection[Number.parseInt(i.toString(), 10)]);
|
|
41167
|
+
}
|
|
41168
|
+
}
|
|
41169
|
+
}
|
|
41170
|
+
_compareFieldItem(item1, item2) {
|
|
41171
|
+
let result = 0;
|
|
41172
|
+
if (typeof item1 !== 'undefined' && typeof item2 !== 'undefined') {
|
|
41173
|
+
const page1 = item1.page;
|
|
41174
|
+
const page2 = item2.page;
|
|
41175
|
+
const array1 = this._getRectangle(item1._dictionary);
|
|
41176
|
+
const array2 = this._getRectangle(item2._dictionary);
|
|
41177
|
+
if (array1 && array2) {
|
|
41178
|
+
const x1 = array1[0];
|
|
41179
|
+
const y1 = array1[1];
|
|
41180
|
+
const x2 = array2[0];
|
|
41181
|
+
const y2 = array2[1];
|
|
41182
|
+
let xdiff;
|
|
41183
|
+
if (this._tabOrder === PdfFormFieldsTabOrder.row) {
|
|
41184
|
+
xdiff = this._compare(page1._pageIndex, page2._pageIndex);
|
|
41185
|
+
if (xdiff !== 0) {
|
|
41186
|
+
result = xdiff;
|
|
41187
|
+
}
|
|
41188
|
+
else {
|
|
41189
|
+
xdiff = this._compare(y2, y1);
|
|
41190
|
+
if (xdiff !== 0) {
|
|
41191
|
+
result = xdiff;
|
|
41192
|
+
}
|
|
41193
|
+
else {
|
|
41194
|
+
result = this._compare(x1, x2);
|
|
41195
|
+
}
|
|
41196
|
+
}
|
|
41197
|
+
}
|
|
41198
|
+
else if (this._tabOrder === PdfFormFieldsTabOrder.column) {
|
|
41199
|
+
xdiff = this._compare(page1._pageIndex, page2._pageIndex);
|
|
41200
|
+
if (xdiff !== 0) {
|
|
41201
|
+
result = xdiff;
|
|
41202
|
+
}
|
|
41203
|
+
else {
|
|
41204
|
+
xdiff = this._compare(x1, x2);
|
|
41205
|
+
if (xdiff !== 0) {
|
|
41206
|
+
result = xdiff;
|
|
41207
|
+
}
|
|
41208
|
+
else {
|
|
41209
|
+
result = this._compare(y2, y1);
|
|
41210
|
+
}
|
|
41211
|
+
}
|
|
41212
|
+
}
|
|
41213
|
+
}
|
|
41214
|
+
}
|
|
41215
|
+
return result;
|
|
41102
41216
|
}
|
|
41103
41217
|
_clear() {
|
|
41104
41218
|
this._fields = [];
|