: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if (node.w === "" || Math.round(w - space.width) <= ERROR) {
return space.height > ERROR;
if (parent[$isThereMoreWidth]()) {
return space.height > ERROR;
if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
if (node.h === "" || Math.round(h + y - space.height) <= ERROR) {
const area = node[$getTemplateRoot]()[$extra].currentContentArea;
if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
return Math.round(h - space.height) <= ERROR;
;// CONCATENATED MODULE: ./src/core/xfa/template.js
const TEMPLATE_NS_ID = NamespaceIds.template.id;
const SVG_NS = "http://www.w3.org/2000/svg";
const MAX_ATTEMPTS_FOR_LRTB_LAYOUT = 2;
const MAX_EMPTY_PAGES = 3;
const DEFAULT_TAB_INDEX = 5000;
const HEADING_PATTERN = /^H(\d+)$/;
const MIMES = new Set(["image/gif", "image/jpeg", "image/jpg", "image/pjpeg", "image/png", "image/apng", "image/x-png", "image/bmp", "image/x-ms-bmp", "image/tiff", "image/tif", "application/octet-stream"]);
const IMAGES_HEADERS = [[[0x42, 0x4d], "image/bmp"], [[0xff, 0xd8, 0xff], "image/jpeg"], [[0x49, 0x49, 0x2a, 0x00], "image/tiff"], [[0x4d, 0x4d, 0x00, 0x2a], "image/tiff"], [[0x47, 0x49, 0x46, 0x38, 0x39, 0x61], "image/gif"], [[0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a], "image/png"]];
function getBorderDims(node) {
if (!node || !node.border) {
const borderExtra = node.border[$getExtra]();
w: borderExtra.widths[0] + borderExtra.widths[2] + borderExtra.insets[0] + borderExtra.insets[2],
h: borderExtra.widths[1] + borderExtra.widths[3] + borderExtra.insets[1] + borderExtra.insets[3]
function hasMargin(node) {
return node.margin && (node.margin.topInset || node.margin.rightInset || node.margin.bottomInset || node.margin.leftInset);
function _setValue(templateNode, value) {
if (!templateNode.value) {
const nodeValue = new Value({});
templateNode[$appendChild](nodeValue);
templateNode.value = nodeValue;
templateNode.value[$setValue](value);
function* getContainedChildren(node) {
for (const child of node[$getChildren]()) {
if (child instanceof SubformSet) {
yield* child[$getContainedChildren]();
function isRequired(node) {
return node.validate?.nullTest === "error";
function setTabIndex(node) {
node[$tabIndex] = node[$getParent]()[$tabIndex];
for (const child of node.traversal[$getChildren]()) {
if (child.operation === "next") {
if (!next || !next.ref) {
node[$tabIndex] = node[$getParent]()[$tabIndex];
const root = node[$getTemplateRoot]();
node[$tabIndex] = ++root[$tabIndex];
const ref = root[$searchNode](next.ref, node);
function applyAssist(obj, attributes) {
const assist = obj.assist;
const assistTitle = assist[$toHTML]();
attributes.title = assistTitle;
const role = assist.role;
const match = role.match(HEADING_PATTERN);
const ariaRole = "heading";
const ariaLevel = match[1];
attributes.role = ariaRole;
attributes["aria-level"] = ariaLevel;
if (obj.layout === "table") {
attributes.role = "table";
} else if (obj.layout === "row") {
const parent = obj[$getParent]();
if (parent.layout === "row") {
attributes.role = parent.assist?.role === "TH" ? "columnheader" : "cell";
function ariaLabel(obj) {
const assist = obj.assist;
if (assist.speak && assist.speak[$content] !== "") {
return assist.speak[$content];
return assist.toolTip[$content];
function valueToHtml(value) {
return HTMLResult.success({
style: Object.create(null)
style: Object.create(null)
function setFirstUnsplittable(node) {
const root = node[$getTemplateRoot]();
if (root[$extra].firstUnsplittable === null) {
root[$extra].firstUnsplittable = node;
root[$extra].noLayoutFailure = true;
function unsetFirstUnsplittable(node) {
const root = node[$getTemplateRoot]();
if (root[$extra].firstUnsplittable === node) {
root[$extra].noLayoutFailure = false;
function handleBreak(node) {
node[$extra] = Object.create(null);
if (node.targetType === "auto") {
const root = node[$getTemplateRoot]();
target = root[$searchNode](node.target, node[$getParent]());
if (node.targetType === "pageArea") {
if (!(target instanceof PageArea)) {
node[$extra].target = target || currentPageArea;
} else if (target && target !== currentPageArea) {
node[$extra].target = target;
if (!(target instanceof ContentArea)) {
const pageArea = target && target[$getParent]();
let nextPageArea = pageArea;
const contentAreas = pageArea.contentArea.children;
const indexForCurrent = contentAreas.indexOf(currentContentArea);
const indexForTarget = contentAreas.indexOf(target);
if (indexForCurrent !== -1 && indexForCurrent < indexForTarget) {
index = indexForTarget - 1;
index = currentPageArea.contentArea.children.indexOf(currentContentArea);
} else if (target && target !== currentContentArea) {
const contentAreas = pageArea.contentArea.children;
index = contentAreas.indexOf(target) - 1;
nextPageArea = pageArea === currentPageArea ? null : pageArea;
node[$extra].target = nextPageArea;
node[$extra].index = index;
function handleOverflow(node, extraNode, space) {
const root = node[$getTemplateRoot]();
const saved = root[$extra].noLayoutFailure;
const savedMethod = extraNode[$getSubformParent];
extraNode[$getSubformParent] = () => node;
root[$extra].noLayoutFailure = true;
const res = extraNode[$toHTML](space);
node[$addHTML](res.html, res.bbox);
root[$extra].noLayoutFailure = saved;
extraNode[$getSubformParent] = savedMethod;
class AppearanceFilter extends StringObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "appearanceFilter");
this.id = attributes.id || "";
this.type = getStringOption(attributes.type, ["optional", "required"]);
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
class Arc extends XFAObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "arc", true);
this.circular = getInteger({
data: attributes.circular,
this.hand = getStringOption(attributes.hand, ["even", "left", "right"]);
this.id = attributes.id || "";
this.startAngle = getFloat({
data: attributes.startAngle,
this.sweepAngle = getFloat({
data: attributes.sweepAngle,
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
const edge = this.edge || new Edge({});
const edgeStyle = edge[$toStyle]();
const style = Object.create(null);
if (this.fill?.presence === "visible") {
Object.assign(style, this.fill[$toStyle]());
style.fill = "transparent";
style.strokeWidth = measureToString(edge.presence === "visible" ? edge.thickness : 0);
style.stroke = edgeStyle.color;
if (this.sweepAngle === 360) {
const startAngle = this.startAngle * Math.PI / 180;
const sweepAngle = this.sweepAngle * Math.PI / 180;
const largeArc = this.sweepAngle > 180 ? 1 : 0;
const [x1, y1, x2, y2] = [50 * (1 + Math.cos(startAngle)), 50 * (1 - Math.sin(startAngle)), 50 * (1 + Math.cos(startAngle + sweepAngle)), 50 * (1 - Math.sin(startAngle + sweepAngle))];
d: `M ${x1} ${y1} A 50 50 0 ${largeArc} 0 ${x2} ${y2}`,
vectorEffect: "non-scaling-stroke",
Object.assign(attributes, {
preserveAspectRatio: "none"
const parent = this[$getParent]()[$getParent]();
return HTMLResult.success({
svg.attributes.style.position = "absolute";
return HTMLResult.success(svg);
class Area extends XFAObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "area", true);
this.colSpan = getInteger({
data: attributes.colSpan,
validate: n => n >= 1 || n === -1
this.id = attributes.id || "";
this.name = attributes.name || "";
this.relevant = getRelevant(attributes.relevant);
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
this.x = getMeasurement(attributes.x, "0pt");
this.y = getMeasurement(attributes.y, "0pt");
this.area = new XFAObjectArray();
this.draw = new XFAObjectArray();
this.exObject = new XFAObjectArray();
this.exclGroup = new XFAObjectArray();
this.field = new XFAObjectArray();
this.subform = new XFAObjectArray();
this.subformSet = new XFAObjectArray();
*[$getContainedChildren]() {
yield* getContainedChildren(this);
const [x, y, w, h] = bbox;
this[$extra].width = Math.max(this[$extra].width, x + w);
this[$extra].height = Math.max(this[$extra].height, y + h);
this[$extra].children.push(html);
return this[$extra].availableSpace;
[$toHTML](availableSpace) {
const style = toStyle(this, "position");
attributes.class.push("xfaPrintOnly");
attributes.xfaName = this.name;
const result = this[$childrenToHTML]({
filter: new Set(["area", "draw", "field", "exclGroup", "subform", "subformSet"]),
return HTMLResult.FAILURE;
style.width = measureToString(this[$extra].width);
style.height = measureToString(this[$extra].height);
const bbox = [this.x, this.y, this[$extra].width, this[$extra].height];
return HTMLResult.success(html, bbox);
class Assist extends XFAObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "assist", true);
this.id = attributes.id || "";
this.role = attributes.role || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
return this.toolTip?.[$content] || null;
class Barcode extends XFAObject {
constructor(attributes) {
super(TEMPLATE_NS_ID, "barcode", true);
this.charEncoding = getKeyword({
data: attributes.charEncoding ? attributes.charEncoding.toLowerCase() : "",
validate: k => ["utf-8", "big-five", "fontspecific", "gbk", "gb-18030", "gb-2312", "ksc-5601", "none", "shift-jis", "ucs-2", "utf-16"].includes(k) || k.match(/iso-8859-\d{2}/)
this.checksum = getStringOption(attributes.checksum, ["none", "1mod10", "1mod10_1mod11", "2mod10", "auto"]);