mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
[JS] Take into account all the required fields for some computations
- Fix Field::getArray in order to collect only the fields which have a value; - Fix AFSimple_Calculate: * allow to have a string with a list of field names as argument; * since a field can be non-terminal, use Field::getArray to collect the field under it and then apply the calculation on all the descendants.
This commit is contained in:
parent
c6cc7c6e6a
commit
e756bb69e4
4 changed files with 154 additions and 10 deletions
|
@ -889,6 +889,24 @@ class Doc extends PDFObject {
|
|||
return children;
|
||||
}
|
||||
|
||||
_getTerminalChildren(fieldName) {
|
||||
// Get all the descendants which have a value.
|
||||
const children = [];
|
||||
const len = fieldName.length;
|
||||
for (const [name, field] of this._fields.entries()) {
|
||||
if (name.startsWith(fieldName)) {
|
||||
const finalPart = name.slice(len);
|
||||
if (
|
||||
field.obj._hasValue &&
|
||||
(finalPart === "" || finalPart.startsWith("."))
|
||||
) {
|
||||
children.push(field.wrapped);
|
||||
}
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
getIcon() {
|
||||
/* Not implemented */
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue