XFA - Create a new page in case of overflow

- it aims to fix #14071;
  - a subform is overflowing and the the target in case of overflow is itself. In this case we must create a new page.
This commit is contained in:
Calixte Denizet 2021-09-24 14:57:51 +02:00
parent c3ca78fdf8
commit cd73e282eb
3 changed files with 20 additions and 19 deletions

View File

@ -4886,12 +4886,6 @@ class Subform extends XFAObject {
return false;
}
const contentArea = this[$getTemplateRoot]()[$extra].currentContentArea;
if (this.overflow && this.overflow[$getExtra]().target === contentArea) {
return false;
}
if (this[$extra]._isSplittable !== undefined) {
return this[$extra]._isSplittable;
}
@ -5025,18 +5019,8 @@ class Subform extends XFAObject {
});
const root = this[$getTemplateRoot]();
const currentContentArea = root[$extra].currentContentArea;
const savedNoLayoutFailure = root[$extra].noLayoutFailure;
if (this.overflow) {
// In case of overflow in the current content area,
// elements must be kept in this subform so it implies
// to have no errors on layout failures.
root[$extra].noLayoutFailure =
root[$extra].noLayoutFailure ||
this.overflow[$getExtra]().target === currentContentArea;
}
const isSplittable = this[$isSplittable]();
if (!isSplittable) {
setFirstUnsplittable(this);
@ -5572,6 +5556,8 @@ class Template extends XFAObject {
flush(i);
const currentIndex = i;
i = Infinity;
if (target instanceof PageArea) {
// We must stop the contentAreas filling and go to the next page.
@ -5579,9 +5565,15 @@ class Template extends XFAObject {
} else if (target instanceof ContentArea) {
const index = contentAreas.findIndex(e => e === target);
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;
if (index > currentIndex) {
// In the next loop iteration `i` will be incremented, note the
// `continue` just below, hence we need to subtract one here.
i = index - 1;
} else {
// The targetted contentArea has already been filled
// so create a new page.
startIndex = index;
}
} else {
targetPageArea = target[$getParent]();
startIndex = targetPageArea.contentArea.children.findIndex(

View File

@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/7225677/eimm5669e.2.pdf

View File

@ -951,6 +951,14 @@
"link": true,
"type": "load"
},
{ "id": "xfa_issue14071",
"file": "pdfs/xfa_issue14071.pdf",
"md5": "7ef09705091602668ce22086c83a90f3",
"link": true,
"rounds": 1,
"enableXfa": true,
"type": "eq"
},
{ "id": "xfa_filled_imm1344e",
"file": "pdfs/xfa_filled_imm1344e.pdf",
"md5": "0576d16692fcd8ef2366cb48bf296e81",