diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index 18ab32450..04dbdbda9 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -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( diff --git a/test/pdfs/xfa_issue14071.pdf.link b/test/pdfs/xfa_issue14071.pdf.link new file mode 100644 index 000000000..e16aa276b --- /dev/null +++ b/test/pdfs/xfa_issue14071.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/7225677/eimm5669e.2.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 008196a58..dffa446d2 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -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",