: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if (!this.subform.children.length) {
return HTMLResult.success({
currentContentArea: null,
blankOrNotBlank: "nonBlank",
const root = this.subform.children[0];
root.pageSet[$cleanPage]();
const pageAreas = root.pageSet.pageArea.children;
let breakBeforeTarget = null;
if (root.breakBefore.children.length >= 1) {
breakBefore = root.breakBefore.children[0];
breakBeforeTarget = breakBefore.target;
} else if (root.subform.children.length >= 1 && root.subform.children[0].breakBefore.children.length >= 1) {
breakBefore = root.subform.children[0].breakBefore.children[0];
breakBeforeTarget = breakBefore.target;
} else if (root.break?.beforeTarget) {
breakBefore = root.break;
breakBeforeTarget = breakBefore.beforeTarget;
} else if (root.subform.children.length >= 1 && root.subform.children[0].break?.beforeTarget) {
breakBefore = root.subform.children[0].break;
breakBeforeTarget = breakBefore.beforeTarget;
const target = this[$searchNode](breakBeforeTarget, breakBefore[$getParent]());
if (target instanceof PageArea) {
breakBefore[$extra] = {};
const pageAreaParent = pageArea[$getParent]();
pageAreaParent[$extra] = {
pageIndex: pageAreaParent.pageArea.children.indexOf(pageArea),
let hasSomethingCounter = 0;
if (++hasSomethingCounter === MAX_EMPTY_PAGES) {
warn("XFA - Something goes wrong: please file a bug.");
this[$extra].currentPageArea = pageArea;
const page = pageArea[$toHTML]().html;
mainHtml.children.push(page);
this[$extra].noLayoutFailure = true;
page.children.push(leader[$toHTML](pageArea[$extra].space).html);
this[$extra].noLayoutFailure = true;
page.children.push(trailer[$toHTML](pageArea[$extra].space).html);
const contentAreas = pageArea.contentArea.children;
const htmlContentAreas = page.children.filter(node => node.attributes.class.includes("xfaContentarea"));
this[$extra].firstUnsplittable = null;
this[$extra].noLayoutFailure = false;
const html = root[$flushHTML]();
hasSomething ||= html.children?.length > 0;
htmlContentAreas[index].children.push(html);
for (let i = startIndex, ii = contentAreas.length; i < ii; i++) {
const contentArea = this[$extra].currentContentArea = contentAreas[i];
htmlContentAreas[i].children.push(leader[$toHTML](space).html);
htmlContentAreas[i].children.push(trailer[$toHTML](space).html);
const html = root[$toHTML](space);
hasSomething ||= html.html.children?.length > 0;
htmlContentAreas[i].children.push(html.html);
} else if (!hasSomething && mainHtml.children.length > 1) {
const node = html.breakNode;
if (node.targetType === "auto") {
leader = this[$searchNode](node.leader, node[$getParent]());
leader = leader ? leader[0] : null;
trailer = this[$searchNode](node.trailer, node[$getParent]());
trailer = trailer ? trailer[0] : null;
if (node.targetType === "pageArea") {
targetPageArea = node[$extra].target;
} else if (!node[$extra].target) {
targetPageArea = node[$extra].target;
startIndex = node[$extra].index + 1;
if (this[$extra].overflowNode) {
const node = this[$extra].overflowNode;
this[$extra].overflowNode = null;
const overflowExtra = node[$getExtra]();
const target = overflowExtra.target;
overflowExtra.addLeader = overflowExtra.leader !== null;
overflowExtra.addTrailer = overflowExtra.trailer !== null;
if (target instanceof PageArea) {
} else if (target instanceof ContentArea) {
const index = contentAreas.indexOf(target);
if (index > currentIndex) {
targetPageArea = target[$getParent]();
startIndex = targetPageArea.contentArea.children.indexOf(target);
this[$extra].pageNumber += 1;
if (targetPageArea[$isUsable]()) {
targetPageArea[$extra].numberOfUse += 1;
pageArea = targetPageArea || pageArea[$getNextPage]();
class Text extends ContentObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "text");
this.id = attributes.id || "";
this.maxChars = getInteger({
data: attributes.maxChars,
this.name = attributes.name || "";
this.rid = attributes.rid || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
if (child[$namespaceId] === NamespaceIds.xhtml.id) {
warn(`XFA - Invalid content in Text: ${child[$nodeName]}.`);
if (this[$content] instanceof XFAObject) {
if (typeof this[$content] === "string") {
this[$content] = this[$content].replaceAll("\r\n", "\n");
if (typeof this[$content] === "string") {
return this[$content].split(/[\u2029\u2028\n]/).reduce((acc, line) => {
return this[$content][$text]();
[$toHTML](availableSpace) {
if (typeof this[$content] === "string") {
const html = valueToHtml(this[$content]).html;
if (this[$content].includes("\u2029")) {
this[$content].split("\u2029").map(para => para.split(/[\u2028\n]/).reduce((acc, line) => {
}, [])).forEach(lines => {
} else if (/[\u2028\n]/.test(this[$content])) {
this[$content].split(/[\u2028\n]/).forEach(line => {
return HTMLResult.success(html);
return this[$content][$toHTML](availableSpace);
class TextEdit extends XFAObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "textEdit", true);
this.allowRichText = getInteger({
data: attributes.allowRichText,
this.hScrollPolicy = getStringOption(attributes.hScrollPolicy, ["auto", "off", "on"]);
this.id = attributes.id || "";
this.multiLine = getInteger({
data: attributes.multiLine,
validate: x => x === 0 || x === 1
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
this.vScrollPolicy = getStringOption(attributes.vScrollPolicy, ["auto", "off", "on"]);
[$toHTML](availableSpace) {
const style = toStyle(this, "border", "font", "margin");
const field = this[$getParent]()[$getParent]();
if (this.multiLine === "") {
this.multiLine = field instanceof Draw ? 1 : 0;
if (this.multiLine === 1) {
dataId: field[$data]?.[$uid] || field[$uid],
"aria-label": ariaLabel(field),
dataId: field[$data]?.[$uid] || field[$uid],
"aria-label": ariaLabel(field),
html.attributes["aria-required"] = true;
html.attributes.required = true;
return HTMLResult.success({
class Time extends StringObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "time");
this.id = attributes.id || "";
this.name = attributes.name || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
const date = this[$content].trim();
this[$content] = date ? new Date(date) : null;
[$toHTML](availableSpace) {
return valueToHtml(this[$content] ? this[$content].toString() : "");
class TimeStamp extends XFAObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "timeStamp");
this.id = attributes.id || "";
this.server = attributes.server || "";
this.type = getStringOption(attributes.type, ["optional", "required"]);
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
class ToolTip extends StringObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "toolTip");
this.id = attributes.id || "";
this.rid = attributes.rid || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
class Traversal extends XFAObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "traversal", true);
this.id = attributes.id || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
this.traverse = new XFAObjectArray();
class Traverse extends XFAObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "traverse", true);
this.id = attributes.id || "";
this.operation = getStringOption(attributes.operation, ["next", "back", "down", "first", "left", "right", "up"]);
this.ref = attributes.ref || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
class Ui extends XFAObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "ui", true);
this.id = attributes.id || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
this.dateTimeEdit = null;
this.passwordEdit = null;
if (this[$extra] === undefined) {
for (const name of Object.getOwnPropertyNames(this)) {
if (name === "extras" || name === "picture") {
if (!(obj instanceof XFAObject)) {
[$toHTML](availableSpace) {
const obj = this[$getExtra]();
return obj[$toHTML](availableSpace);
class Validate extends XFAObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "validate", true);
this.formatTest = getStringOption(attributes.formatTest, ["warning", "disabled", "error"]);
this.id = attributes.id || "";
this.nullTest = getStringOption(attributes.nullTest, ["disabled", "error", "warning"]);
this.scriptTest = getStringOption(attributes.scriptTest, ["error", "disabled", "warning"]);
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
class Value extends XFAObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "value", true);
this.id = attributes.id || "";
this.override = getInteger({
data: attributes.override,
this.relevant = getRelevant(attributes.relevant);
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
const parent = this[$getParent]();