diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index 80fcd4071..c0ec58cfd 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -2753,6 +2753,8 @@ class Field extends XFAObject { let value = ""; if (this.value.exData) { value = this.value.exData[$text](); + } else if (this.value.text) { + value = this.value.text[$getExtra](); } else { const htmlValue = this.value[$toHTML]().html; if (htmlValue !== null) { @@ -5418,6 +5420,27 @@ class Text extends ContentObject { super[$onText](str); } + [$finalize]() { + if (typeof this[$content] === "string") { + this[$content] = this[$content].replace(/\r\n/g, "\n"); + } + } + + [$getExtra]() { + if (typeof this[$content] === "string") { + return this[$content] + .split(/[\u2029\u2028\n]/) + .reduce((acc, line) => { + if (line) { + acc.push(line); + } + return acc; + }, []) + .join("\n"); + } + return this[$content][$text](); + } + [$toHTML](availableSpace) { if (typeof this[$content] === "string") { // \u2028 is a line separator.