-
-
Notifications
You must be signed in to change notification settings - Fork 556
Open
Description
When generating a DOCX file, the document fails to open correctly if a Textbox element is used as the first (or only) child within a Paragraph. The document opens successfully only when the Textbox is preceded by at least one TextRun element in the same paragraph.
Failing Case (Document Corrupted):
const doc = new Document({
sections: [{
properties: {},
children: [
new Paragraph({
children: [
new Textbox({ // ⚠️ Fails as first child
alignment: "center",
children: [new Paragraph({ children: [new TextRun("Hi i'm a textbox!")] })],
style: { width: "200pt", height: "auto" }
})
]
})
]
}]
});
Working Case (Document Opens):
const doc = new Document({
sections: [{
properties: {},
children: [
new Paragraph({
children: [
new TextRun("Hello World"), // ✅ Required before Textbox
new Textbox({
alignment: "center",
children: [new Paragraph({ children: [new TextRun("Hi i'm a textbox!")] })],
style: { width: "200pt", height: "auto" }
})
]
})
]
}]
});
Metadata
Metadata
Assignees
Labels
No labels