Merge pull request #13732 from calixteman/rect
XFA - A rectangle must have the width of its parent but without inner margins
This commit is contained in:
commit
4b2e0d0d01
@ -115,6 +115,16 @@ const MAX_ATTEMPTS_FOR_LRTB_LAYOUT = 2;
|
|||||||
// the loop after having MAX_EMPTY_PAGES empty pages.
|
// the loop after having MAX_EMPTY_PAGES empty pages.
|
||||||
const MAX_EMPTY_PAGES = 3;
|
const MAX_EMPTY_PAGES = 3;
|
||||||
|
|
||||||
|
function hasMargin(node) {
|
||||||
|
return (
|
||||||
|
node.margin &&
|
||||||
|
(node.margin.topInset ||
|
||||||
|
node.margin.rightInset ||
|
||||||
|
node.margin.bottomInset ||
|
||||||
|
node.margin.leftInset)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function _setValue(templateNode, value) {
|
function _setValue(templateNode, value) {
|
||||||
if (!templateNode.value) {
|
if (!templateNode.value) {
|
||||||
const nodeValue = new Value({});
|
const nodeValue = new Value({});
|
||||||
@ -327,16 +337,16 @@ class Arc extends XFAObject {
|
|||||||
style.fill = "transparent";
|
style.fill = "transparent";
|
||||||
}
|
}
|
||||||
style.strokeWidth = measureToString(
|
style.strokeWidth = measureToString(
|
||||||
edge.presence === "visible" ? Math.round(edge.thickness) : 0
|
edge.presence === "visible" ? edge.thickness : 0
|
||||||
);
|
);
|
||||||
style.stroke = edgeStyle.color;
|
style.stroke = edgeStyle.color;
|
||||||
let arc;
|
let arc;
|
||||||
const attributes = {
|
const attributes = {
|
||||||
xmlns: SVG_NS,
|
xmlns: SVG_NS,
|
||||||
style: {
|
style: {
|
||||||
position: "absolute",
|
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
|
overflow: "visible",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -379,12 +389,30 @@ class Arc extends XFAObject {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return HTMLResult.success({
|
const svg = {
|
||||||
name: "svg",
|
name: "svg",
|
||||||
children: [arc],
|
children: [arc],
|
||||||
attributes,
|
attributes,
|
||||||
|
};
|
||||||
|
|
||||||
|
const parent = this[$getParent]()[$getParent]();
|
||||||
|
if (hasMargin(parent)) {
|
||||||
|
return HTMLResult.success({
|
||||||
|
name: "div",
|
||||||
|
attributes: {
|
||||||
|
style: {
|
||||||
|
display: "inline",
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
children: [svg],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
svg.attributes.style.position = "absolute";
|
||||||
|
return HTMLResult.success(svg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Area extends XFAObject {
|
class Area extends XFAObject {
|
||||||
@ -3300,8 +3328,7 @@ class Line extends XFAObject {
|
|||||||
const edge = this.edge ? this.edge : new Edge({});
|
const edge = this.edge ? this.edge : new Edge({});
|
||||||
const edgeStyle = edge[$toStyle]();
|
const edgeStyle = edge[$toStyle]();
|
||||||
const style = Object.create(null);
|
const style = Object.create(null);
|
||||||
const thickness =
|
const thickness = edge.presence === "visible" ? edge.thickness : 0;
|
||||||
edge.presence === "visible" ? Math.round(edge.thickness) : 0;
|
|
||||||
style.strokeWidth = measureToString(thickness);
|
style.strokeWidth = measureToString(thickness);
|
||||||
style.stroke = edgeStyle.color;
|
style.stroke = edgeStyle.color;
|
||||||
let x1, y1, x2, y2;
|
let x1, y1, x2, y2;
|
||||||
@ -3334,7 +3361,7 @@ class Line extends XFAObject {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return HTMLResult.success({
|
const svg = {
|
||||||
name: "svg",
|
name: "svg",
|
||||||
children: [line],
|
children: [line],
|
||||||
attributes: {
|
attributes: {
|
||||||
@ -3342,11 +3369,28 @@ class Line extends XFAObject {
|
|||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
style: {
|
style: {
|
||||||
position: "absolute",
|
overflow: "visible",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
if (hasMargin(parent)) {
|
||||||
|
return HTMLResult.success({
|
||||||
|
name: "div",
|
||||||
|
attributes: {
|
||||||
|
style: {
|
||||||
|
display: "inline",
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
children: [svg],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
svg.attributes.style.position = "absolute";
|
||||||
|
return HTMLResult.success(svg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Linear extends XFAObject {
|
class Linear extends XFAObject {
|
||||||
@ -4204,7 +4248,7 @@ class Rectangle extends XFAObject {
|
|||||||
style.fill = "transparent";
|
style.fill = "transparent";
|
||||||
}
|
}
|
||||||
style.strokeWidth = measureToString(
|
style.strokeWidth = measureToString(
|
||||||
edge.presence === "visible" ? 2 * edge.thickness : 0
|
edge.presence === "visible" ? edge.thickness : 0
|
||||||
);
|
);
|
||||||
style.stroke = edgeStyle.color;
|
style.stroke = edgeStyle.color;
|
||||||
|
|
||||||
@ -4227,19 +4271,37 @@ class Rectangle extends XFAObject {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return HTMLResult.success({
|
const svg = {
|
||||||
name: "svg",
|
name: "svg",
|
||||||
children: [rect],
|
children: [rect],
|
||||||
attributes: {
|
attributes: {
|
||||||
xmlns: SVG_NS,
|
xmlns: SVG_NS,
|
||||||
style: {
|
style: {
|
||||||
position: "absolute",
|
overflow: "visible",
|
||||||
},
|
},
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const parent = this[$getParent]()[$getParent]();
|
||||||
|
if (hasMargin(parent)) {
|
||||||
|
return HTMLResult.success({
|
||||||
|
name: "div",
|
||||||
|
attributes: {
|
||||||
|
style: {
|
||||||
|
display: "inline",
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
children: [svg],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
svg.attributes.style.position = "absolute";
|
||||||
|
return HTMLResult.success(svg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RefElement extends StringObject {
|
class RefElement extends StringObject {
|
||||||
|
1
test/pdfs/xfa_issue13584.pdf.link
Normal file
1
test/pdfs/xfa_issue13584.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://web.archive.org/web/20210518165046/http://education.ohio.gov/getattachment/Topics/Special-Education/Preschool-Special-Education/ETR-Preschool-Planning-Form.pdf.aspx
|
@ -1184,6 +1184,14 @@
|
|||||||
"enableXfa": true,
|
"enableXfa": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "xfa_issue13584",
|
||||||
|
"file": "pdfs/xfa_issue13584.pdf",
|
||||||
|
"md5": "c41af0754dabd81996a0d54db1900beb",
|
||||||
|
"link": true,
|
||||||
|
"rounds": 1,
|
||||||
|
"enableXfa": true,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "xfa_issue13597",
|
{ "id": "xfa_issue13597",
|
||||||
"file": "pdfs/xfa_issue13597.pdf",
|
"file": "pdfs/xfa_issue13597.pdf",
|
||||||
"md5": "1ed9338f7e797789c0b41182f51b9002",
|
"md5": "1ed9338f7e797789c0b41182f51b9002",
|
||||||
|
Loading…
Reference in New Issue
Block a user