@syncfusion/ej2-pdf
Advanced tools
Comparing version 24.2.8 to 24.2.9
@@ -9,2 +9,10 @@ # Changelog | ||
- Resolved an exception encountered while importing annotations from JSON file with custom data. | ||
## 24.2.8 (2024-02-27) | ||
### PDF Parser | ||
#### Bug Fixes | ||
- The script error thrown while parsing the PDF document has been resolved. | ||
@@ -11,0 +19,0 @@ |
/*! | ||
* filename: index.d.ts | ||
* version : 24.2.8 | ||
* version : 24.2.9 | ||
* Copyright Syncfusion Inc. 2001 - 2023. All rights reserved. | ||
@@ -5,0 +5,0 @@ * Use of this code is subject to the terms of our license. |
{ | ||
"_from": "@syncfusion/ej2-pdf@*", | ||
"_id": "@syncfusion/ej2-pdf@24.2.7", | ||
"_id": "@syncfusion/ej2-pdf@24.2.8", | ||
"_inBundle": false, | ||
"_integrity": "sha512-zKAbVJ6XijhD/M1TfsTput/9SCdZgD5zj79PozijBc6h66Gk06sWq4cDl1O+Pp9V9pVe/PxYhqphK5XBvtfe/A==", | ||
"_integrity": "sha512-sldIPEmlR0Cod7QoBhd2U/a2NviS+rMh1/tIbW3GddUkHm9+kfyVFYNbCpGdiq/FAn90MJldMsDfFf+TdkziYQ==", | ||
"_location": "/@syncfusion/ej2-pdf", | ||
@@ -24,4 +24,4 @@ "_phantomChildren": {}, | ||
], | ||
"_resolved": "https://nexus.syncfusioninternal.com/repository/ej2-hotfix-new/@syncfusion/ej2-pdf/-/ej2-pdf-24.2.7.tgz", | ||
"_shasum": "96197a90af3ba0c040e677f74649c3d5c9253c24", | ||
"_resolved": "https://nexus.syncfusioninternal.com/repository/ej2-hotfix-new/@syncfusion/ej2-pdf/-/ej2-pdf-24.2.8.tgz", | ||
"_shasum": "d9cc1f127ba22c3435f75b4988880810ffe74970", | ||
"_spec": "@syncfusion/ej2-pdf@*", | ||
@@ -59,5 +59,5 @@ "_where": "/jenkins/workspace/elease-automation_release_24.1.1/packages/included", | ||
"typings": "index.d.ts", | ||
"version": "24.2.8", | ||
"version": "24.2.9", | ||
"sideEffects": false, | ||
"homepage": "https://www.syncfusion.com/javascript-ui-controls" | ||
} |
@@ -5,2 +5,3 @@ import { _PdfDictionary, _PdfName, _PdfReference } from './../pdf-primitives'; | ||
import { PdfFormFieldsTabOrder, _SignatureFlag } from './../enumerator'; | ||
import { PdfPage } from './../pdf-page'; | ||
/** | ||
@@ -277,5 +278,9 @@ * Represents a PDF form. | ||
_getRectangle(dictionary: _PdfDictionary): number[]; | ||
_getItemRectangle(field: PdfField): number[]; | ||
_compare(x: number, y: number): number; | ||
_compareKidsElement(x: _PdfReference, y: _PdfReference): number; | ||
_sortItemByPageIndex(field: PdfField, hasPageTabOrder: boolean): PdfPage; | ||
_sortFieldItems(field: PdfField): void; | ||
_compareFieldItem(item1: any, item2: any): number; | ||
_clear(): void; | ||
} |
@@ -380,3 +380,3 @@ import { _PdfDictionary, _PdfName, _PdfReference } from './../pdf-primitives'; | ||
if (field.page) { | ||
var index = _getPageIndex(document_1, field.page._pageDictionary); | ||
var index = _getPageIndex(document_1, this._sortItemByPageIndex(field, true)._pageDictionary); | ||
if (index >= 0) { | ||
@@ -405,12 +405,14 @@ if (fieldCollection.has(index)) { | ||
_this._tabOrder = _this._tabCollection.get(key); | ||
var fields = value; | ||
fields.sort(function (pdfField1, pdfField2) { | ||
return _this._compareFields(pdfField1, pdfField2); | ||
}); | ||
for (var j = 0; j < fields.length; j++) { | ||
var fieldIndex = _this._fieldCollection.indexOf(fields[Number.parseInt(j.toString(), 10)]); | ||
if (fieldIndex !== -1 && fieldIndex !== fieldsCount_1 + j) { | ||
var field = _this._fieldCollection[Number.parseInt(fieldIndex.toString(), 10)]; | ||
_this._fieldCollection.splice(fieldIndex, 1); | ||
_this._fieldCollection.splice(fieldsCount_1 + j, 0, field); | ||
if (_this._tabOrder !== PdfFormFieldsTabOrder.structure) { | ||
var fields = value; | ||
fields.sort(function (pdfField1, pdfField2) { | ||
return _this._compareFields(pdfField1, pdfField2); | ||
}); | ||
for (var j = 0; j < fields.length; j++) { | ||
var fieldIndex = _this._fieldCollection.indexOf(fields[Number.parseInt(j.toString(), 10)]); | ||
if (fieldIndex !== -1 && fieldIndex !== fieldsCount_1 + j) { | ||
var field = _this._fieldCollection[Number.parseInt(fieldIndex.toString(), 10)]; | ||
_this._fieldCollection.splice(fieldIndex, 1); | ||
_this._fieldCollection.splice(fieldsCount_1 + j, 0, field); | ||
} | ||
} | ||
@@ -655,6 +657,20 @@ } | ||
if (page1 && page1 instanceof PdfPage && page2 && page2 instanceof PdfPage) { | ||
var page1Index = page1._pageIndex; | ||
var page2Index = page2._pageIndex; | ||
var rectangle1 = this._getRectangle(field1._dictionary); | ||
var rectangle2 = this._getRectangle(field2._dictionary); | ||
var page1Index = this._sortItemByPageIndex(field1, false)._pageIndex; | ||
var page2Index = this._sortItemByPageIndex(field2, false)._pageIndex; | ||
var rectangle1 = void 0; | ||
if (field1._dictionary.has('Kids')) { | ||
rectangle1 = this._getItemRectangle(field1); | ||
} | ||
else { | ||
rectangle1 = this._getRectangle(field1._dictionary); | ||
} | ||
var rectangle2 = void 0; | ||
if (field2._dictionary.has('Kids')) { | ||
rectangle2 = this._getItemRectangle(field2); | ||
} | ||
else { | ||
rectangle2 = this._getRectangle(field2._dictionary); | ||
} | ||
var firstHeight = rectangle1[3] - rectangle1[1]; | ||
var secondHeight = rectangle2[3] - rectangle2[1]; | ||
if (rectangle1 && rectangle1.length >= 2 && rectangle2 && rectangle2.length >= 2) { | ||
@@ -670,2 +686,9 @@ var x1 = rectangle1[0]; | ||
xdiff = this._compare(y2, y1); | ||
if (xdiff !== 0) { | ||
var isValid = xdiff === -1 && y1 > y2 && (y1 - firstHeight / 2) < y2; | ||
isValid = isValid || (xdiff === 1 && y2 > y1 && (y2 - secondHeight / 2) < y1); | ||
if (isValid) { | ||
xdiff = 0; | ||
} | ||
} | ||
if (index !== 0) { | ||
@@ -713,24 +736,28 @@ result = index; | ||
PdfForm.prototype._getRectangle = function (dictionary) { | ||
var _this = this; | ||
var rect; | ||
if (dictionary.has('Rect')) { | ||
var rect = dictionary.get('Rect'); | ||
if (rect) { | ||
return rect; | ||
} | ||
rect = dictionary.getArray('Rect'); | ||
} | ||
else { | ||
if (dictionary.has('Kids')) { | ||
var kidsArray = dictionary.get('Kids'); | ||
if (kidsArray) { | ||
if (kidsArray.length > 1) { | ||
kidsArray.sort(function (x, y) { | ||
return _this._compareKidsElement(x, y); | ||
}); | ||
return rect; | ||
}; | ||
PdfForm.prototype._getItemRectangle = function (field) { | ||
var result; | ||
var dictionary = field._dictionary; | ||
if (dictionary.has('Kids')) { | ||
var kids = dictionary.getArray('Kids'); | ||
if (kids && kids.length >= 1) { | ||
if (kids.length === 1) { | ||
result = this._getRectangle(kids[0]); | ||
} | ||
else { | ||
if (field && field.itemsCount > 1) { | ||
result = this._getRectangle(field.itemAt(0)._dictionary); | ||
} | ||
var dictionary_1 = this._crossReference._fetch(kidsArray[0]); | ||
return this._getRectangle(dictionary_1); | ||
else { | ||
result = this._getRectangle(kids[0]); | ||
} | ||
} | ||
} | ||
} | ||
return null; | ||
return result; | ||
}; | ||
@@ -753,2 +780,3 @@ PdfForm.prototype._compare = function (x, y) { | ||
var yRect = this._getRectangle(yDictionary); | ||
var result; | ||
if (xRect && xRect.length >= 2 && yRect && yRect.length >= 2) { | ||
@@ -761,3 +789,2 @@ var x1 = xRect[0]; | ||
typeof y1 === 'number' && typeof y2 === 'number') { | ||
var result = 0; | ||
var xdiff = void 0; | ||
@@ -782,7 +809,87 @@ if (this._tabOrder === PdfFormFieldsTabOrder.row) { | ||
} | ||
else { | ||
result = 0; | ||
} | ||
return result; | ||
} | ||
} | ||
return null; | ||
return result; | ||
}; | ||
PdfForm.prototype._sortItemByPageIndex = function (field, hasPageTabOrder) { | ||
var page = field.page; | ||
var tabOrder = this._tabOrder; | ||
this._tabOrder = hasPageTabOrder ? field.page.tabOrder : tabOrder; | ||
this._sortFieldItems(field); | ||
if (field._isLoaded && field._kidsCount > 1) { | ||
page = field.itemAt(0).page; | ||
} | ||
this._tabOrder = tabOrder; | ||
if (typeof page === 'undefined') { | ||
page = field.page; | ||
} | ||
return page; | ||
}; | ||
PdfForm.prototype._sortFieldItems = function (field) { | ||
var _this = this; | ||
if (field._isLoaded && (field instanceof PdfTextBoxField || | ||
field instanceof PdfListBoxField || | ||
field instanceof PdfCheckBoxField || | ||
field instanceof PdfRadioButtonListField)) { | ||
var collection = field._parseItems(); // eslint-disable-line | ||
collection.sort(function (item1, item2) { | ||
return _this._compareFieldItem(item1, item2); | ||
}); | ||
field._parsedItems.clear(); | ||
for (var i = 0; i < collection.length; i++) { | ||
field._parsedItems.set(i, collection[Number.parseInt(i.toString(), 10)]); | ||
} | ||
} | ||
}; | ||
PdfForm.prototype._compareFieldItem = function (item1, item2) { | ||
var result = 0; | ||
if (typeof item1 !== 'undefined' && typeof item2 !== 'undefined') { | ||
var page1 = item1.page; | ||
var page2 = item2.page; | ||
var array1 = this._getRectangle(item1._dictionary); | ||
var array2 = this._getRectangle(item2._dictionary); | ||
if (array1 && array2) { | ||
var x1 = array1[0]; | ||
var y1 = array1[1]; | ||
var x2 = array2[0]; | ||
var y2 = array2[1]; | ||
var xdiff = void 0; | ||
if (this._tabOrder === PdfFormFieldsTabOrder.row) { | ||
xdiff = this._compare(page1._pageIndex, page2._pageIndex); | ||
if (xdiff !== 0) { | ||
result = xdiff; | ||
} | ||
else { | ||
xdiff = this._compare(y2, y1); | ||
if (xdiff !== 0) { | ||
result = xdiff; | ||
} | ||
else { | ||
result = this._compare(x1, x2); | ||
} | ||
} | ||
} | ||
else if (this._tabOrder === PdfFormFieldsTabOrder.column) { | ||
xdiff = this._compare(page1._pageIndex, page2._pageIndex); | ||
if (xdiff !== 0) { | ||
result = xdiff; | ||
} | ||
else { | ||
xdiff = this._compare(x1, x2); | ||
if (xdiff !== 0) { | ||
result = xdiff; | ||
} | ||
else { | ||
result = this._compare(y2, y1); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return result; | ||
}; | ||
PdfForm.prototype._clear = function () { | ||
@@ -789,0 +896,0 @@ this._fields = []; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22484345
175688