XFA - Handle startIndex
correctly in the Template.$toHTML
method (issue 13751)
*Please note:* The PDF document in issue 13751 is *dynamically* created (in e.g. Adobe Reader), with pages added when certain buttons are clicked, hence this patch simply fixes the breaking error and nothing more. It looks like the current code contains a little bit too much copy-and-paste from the *similar* `index` branch above, since we cannot set the `startIndex` to a negative value. Note how it's being used to initialize the loop-variable, which is then used to lookup values in an Array and accessing the `-1`th element of an Array obviously makes no sense.
This commit is contained in:
parent
6c9b6bc599
commit
7d1c19f8bd
@ -5288,13 +5288,14 @@ class Template extends XFAObject {
|
|||||||
} else if (target instanceof ContentArea) {
|
} else if (target instanceof ContentArea) {
|
||||||
const index = contentAreas.findIndex(e => e === target);
|
const index = contentAreas.findIndex(e => e === target);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
|
// In the next loop iteration `i` will be incremented, note the
|
||||||
|
// `continue` just below, hence we need to subtract one here.
|
||||||
i = index - 1;
|
i = index - 1;
|
||||||
} else {
|
} else {
|
||||||
targetPageArea = target[$getParent]();
|
targetPageArea = target[$getParent]();
|
||||||
startIndex =
|
startIndex = targetPageArea.contentArea.children.findIndex(
|
||||||
targetPageArea.contentArea.children.findIndex(
|
e => e === target
|
||||||
e => e === target
|
);
|
||||||
) - 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
1
test/pdfs/issue13751.pdf.link
Normal file
1
test/pdfs/issue13751.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/mozilla/pdf.js/files/6834770/Oswiadczenie_o_statusie_FATCA_i_CRS-1.pdf
|
@ -1356,6 +1356,15 @@
|
|||||||
"enableXfa": true,
|
"enableXfa": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "issue13751",
|
||||||
|
"file": "pdfs/issue13751.pdf",
|
||||||
|
"md5": "b9960bfa99be3573d9c32a9d55e5b7da",
|
||||||
|
"link": true,
|
||||||
|
"rounds": 1,
|
||||||
|
"lastPage": 1,
|
||||||
|
"enableXfa": true,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "issue13756",
|
{ "id": "issue13756",
|
||||||
"file": "pdfs/issue13756.pdf",
|
"file": "pdfs/issue13756.pdf",
|
||||||
"md5": "67040c6df3b5039fcbc81bf63b7c7f98",
|
"md5": "67040c6df3b5039fcbc81bf63b7c7f98",
|
||||||
|
Loading…
Reference in New Issue
Block a user