-
-
Notifications
You must be signed in to change notification settings - Fork 566
-
I’m new to docx.js and need to insert a floating TextBox in my document header that has no fill and no visible border just the text itself. Every approach I’ve tried still produces a white background or outlines around the box.
Is there a built-in way in docx.js to make a Textbox completely transparent and remove its borders? Any guidance or simple examples would be really helpful. Thanks!
I am using 9.3.0 version.
Beta Was this translation helpful? Give feedback.
All reactions
maybe not best solution but fixed it by fetching and patching object xml. Replaced parts that needed change with this logic:
` const patchedXml = documentXml.replace(/<v:shape([^>]*?)>/g, (match, existingAttrs) => {
let attrs = existingAttrs;
if (!/filled="f"/.test(attrs)) attrs += ' filled="f"';
if (!/stroked="f"/.test(attrs)) attrs += ' stroked="f"';
if (/style="([^"]*)"/.test(attrs)) {
attrs = attrs.replace(/style="([^"]*)"/, (m, styleContent) => {
let updatedStyle = styleContent;
if (!/mso-wrap-style:/.test(updatedStyle)) updatedStyle += ';mso-wrap-style:behind';
return `style="${updatedStyle}"`;
});
} else {
attrs += ' style="position:absolute;z...Replies: 1 comment
-
maybe not best solution but fixed it by fetching and patching object xml. Replaced parts that needed change with this logic:
` const patchedXml = documentXml.replace(/<v:shape([^>]*?)>/g, (match, existingAttrs) => {
let attrs = existingAttrs;
if (!/filled="f"/.test(attrs)) attrs += ' filled="f"';
if (!/stroked="f"/.test(attrs)) attrs += ' stroked="f"';
if (/style="([^"]*)"/.test(attrs)) {
attrs = attrs.replace(/style="([^"]*)"/, (m, styleContent) => {
let updatedStyle = styleContent;
if (!/mso-wrap-style:/.test(updatedStyle)) updatedStyle += ';mso-wrap-style:behind';
return `style="${updatedStyle}"`;
});
} else {
attrs += ' style="position:absolute;z-index:-251658240;mso-wrap-style:none"';
}
return `<v:shape${attrs}>`;
});`
Beta Was this translation helpful? Give feedback.