: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
[$isDescendent](parent) {
return this[_parent] === parent || this[_parent][$isDescendent](parent);
class XmlObject extends XFAObject {
constructor(nsId, name, attributes = {}) {
for (const [attrName, value] of Object.entries(attributes)) {
map.set(attrName, new XFAAttribute(this, attrName, value));
if (attributes.hasOwnProperty($nsAttributes)) {
const dataNode = attributes[$nsAttributes].xfa.dataNode;
if (dataNode !== undefined) {
if (dataNode === "dataGroup") {
this[_dataValue] = false;
} else if (dataNode === "dataValue") {
const tagName = this[$nodeName];
if (tagName === "#text") {
buf.push(encodeToXmlString(this[$content]));
const utf8TagName = utf8StringToString(tagName);
const prefix = this[$namespaceId] === NS_DATASETS ? "xfa:" : "";
buf.push(`<${prefix}${utf8TagName}`);
for (const [name, value] of this[_attributes].entries()) {
const utf8Name = utf8StringToString(name);
buf.push(` ${utf8Name}="${encodeToXmlString(value[$content])}"`);
if (this[_dataValue] !== null) {
buf.push(` xfa:dataNode="dataValue"`);
buf.push(` xfa:dataNode="dataGroup"`);
if (!this[$content] && this[_children].length === 0) {
if (typeof this[$content] === "string") {
buf.push(encodeToXmlString(this[$content]));
this[$content][$toString](buf);
for (const child of this[_children]) {
buf.push(`</${prefix}${utf8TagName}>`);
const node = new XmlObject(this[$namespaceId], "#text");
this[$appendChild](node);
node[$content] = this[$content];
this[$appendChild](child);
if (this[$content] && this[_children].length > 0) {
const node = new XmlObject(this[$namespaceId], "#text");
this[$appendChild](node);
node[$content] = this[$content];
if (this[$nodeName] === "#text") {
return HTMLResult.success({
[$getChildren](name = null) {
return this[_children].filter(c => c[$nodeName] === name);
return this[_attributes];
[$getChildrenByClass](name) {
const value = this[_attributes].get(name);
if (value !== undefined) {
return this[$getChildren](name);
*[$getChildrenByNameIt](name, allTransparent) {
const value = this[_attributes].get(name);
for (const child of this[_children]) {
if (child[$nodeName] === name) {
yield* child[$getChildrenByNameIt](name, allTransparent);
*[$getAttributeIt](name, skipConsumed) {
const value = this[_attributes].get(name);
if (value && (!skipConsumed || !value[$consumed])) {
for (const child of this[_children]) {
yield* child[$getAttributeIt](name, skipConsumed);
*[$getRealChildrenByNameIt](name, allTransparent, skipConsumed) {
for (const child of this[_children]) {
if (child[$nodeName] === name && (!skipConsumed || !child[$consumed])) {
yield* child[$getRealChildrenByNameIt](name, allTransparent, skipConsumed);
if (this[_dataValue] === null) {
return this[_children].length === 0 || this[_children][0][$namespaceId] === NamespaceIds.xhtml.id;
if (this[_dataValue] === null) {
if (this[_children].length === 0) {
return this[$content].trim();
if (this[_children][0][$namespaceId] === NamespaceIds.xhtml.id) {
return this[_children][0][$text]().trim();
return this[$content].trim();
value = value.value || "";
this[$content] = value.toString();
const dumped = Object.create(null);
dumped.$ns = this[$namespaceId];
dumped.$content = this[$content];
dumped.$name = this[$nodeName];
for (const child of this[_children]) {
dumped.children.push(child[$dump](hasNS));
dumped.attributes = Object.create(null);
for (const [name, value] of this[_attributes]) {
dumped.attributes[name] = value[$content];
class ContentObject extends XFAObject {
constructor(nsId, name) {
class OptionObject extends ContentObject {
constructor(nsId, name, options) {
this[_options] = options;
this[$content] = getKeyword({
defaultValue: this[_options][0],
validate: k => this[_options].includes(k)
class StringObject extends ContentObject {
this[$content] = this[$content].trim();
class IntegerObject extends ContentObject {
constructor(nsId, name, defaultValue, validator) {
this[_defaultValue] = defaultValue;
this[_validator] = validator;
this[$content] = getInteger({
defaultValue: this[_defaultValue],
validate: this[_validator]
delete this[_defaultValue];
class Option01 extends IntegerObject {
constructor(nsId, name) {
super(nsId, name, 0, n => n === 1);
class Option10 extends IntegerObject {
constructor(nsId, name) {
super(nsId, name, 1, n => n === 0);
;// CONCATENATED MODULE: ./src/core/xfa/html_utils.js
function measureToString(m) {
if (typeof m === "string") {
return Number.isInteger(m) ? `${m}px` : `${m.toFixed(2)}px`;
anchorType(node, style) {
const parent = node[$getSubformParent]();
if (!parent || parent.layout && parent.layout !== "position") {
if (!("transform" in style)) {
switch (node.anchorType) {
style.transform += "translate(-50%, -100%)";
style.transform += "translate(0,-100%)";
style.transform += "translate(-100%,-100%)";
style.transform += "translate(-50%,-50%)";
style.transform += "translate(0,-50%)";
style.transform += "translate(-100%,-50%)";
style.transform += "translate(-50%,0)";
style.transform += "translate(-100%,0)";
dimensions(node, style) {
const parent = node[$getSubformParent]();
if (parent.layout?.includes("row")) {
const extra = parent[$extra];
const colSpan = node.colSpan;
w = extra.columnWidths.slice(extra.currentColumn).reduce((a, x) => a + x, 0);
w = extra.columnWidths.slice(extra.currentColumn, extra.currentColumn + colSpan).reduce((a, x) => a + x, 0);
extra.currentColumn = (extra.currentColumn + node.colSpan) % extra.columnWidths.length;
style.width = width !== "" ? measureToString(width) : "auto";
style.height = height !== "" ? measureToString(height) : "auto";
const parent = node[$getSubformParent]();
if (parent?.layout && parent.layout !== "position") {
style.position = "absolute";
style.left = measureToString(node.x);
style.top = measureToString(node.y);
if (!("transform" in style)) {
style.transform += `rotate(-${node.rotate}deg)`;
style.transformOrigin = "top left";
style.visibility = "hidden";
if (node[$nodeName] === "para") {
style.textAlign = "justify-all";
style.textAlign = "left";
style.textAlign = node.hAlign;
style.alignSelf = "start";
style.alignSelf = "center";
style.margin = node.margin[$toStyle]().margin;
function setMinMaxDimensions(node, style) {
const parent = node[$getSubformParent]();
if (parent.layout === "position") {
style.minWidth = measureToString(node.minW);
style.maxWidth = measureToString(node.maxW);
style.minHeight = measureToString(node.minH);
style.maxHeight = measureToString(node.maxH);
function layoutText(text, xfaFont, margin, lineHeight, fontFinder, width) {
const measure = new TextMeasure(xfaFont, margin, lineHeight, fontFinder);
if (typeof text === "string") {
text[$pushGlyphs](measure);
return measure.compute(width);
function layoutNode(node, availableSpace) {
if ((!node.w || !node.h) && node.value) {
marginH = node.margin.leftInset + node.margin.rightInset;
marginV = node.margin.topInset + node.margin.bottomInset;
margin = Object.create(null);
lineHeight = node.para.lineHeight === "" ? null : node.para.lineHeight;
margin.top = node.para.spaceAbove === "" ? 0 : node.para.spaceAbove;
margin.bottom = node.para.spaceBelow === "" ? 0 : node.para.spaceBelow;
margin.left = node.para.marginLeft === "" ? 0 : node.para.marginLeft;
margin.right = node.para.marginRight === "" ? 0 : node.para.marginRight;
const root = node[$getTemplateRoot]();
let parent = node[$getParent]();
while (parent && parent !== root) {
parent = parent[$getParent]();
const maxWidth = (node.w || availableSpace.width) - marginH;
const fontFinder = node[$globalData].fontFinder;
if (node.value.exData && node.value.exData[$content] && node.value.exData.contentType === "text/html") {
const res = layoutText(node.value.exData[$content], font, margin, lineHeight, fontFinder, maxWidth);
const text = node.value[$text]();
const res = layoutText(text, font, margin, lineHeight, fontFinder, maxWidth);
if (width !== null && !node.w) {
if (height !== null && !node.h) {
function computeBbox(node, html, availableSpace) {
if (node.w !== "" && node.h !== "") {
bbox = [node.x, node.y, node.w, node.h];
const parent = node[$getSubformParent]();
width = parent.layout === "position" && parent.w !== "" ? 0 : node.minW;
width = Math.min(node.maxW, availableSpace.width);
html.attributes.style.width = measureToString(width);
const parent = node[$getSubformParent]();
height = parent.layout === "position" && parent.h !== "" ? 0 : node.minH;
height = Math.min(node.maxH, availableSpace.height);