-
-
Notifications
You must be signed in to change notification settings - Fork 575
Word Online cannot open .docx files generated with [email protected] (works fine in v8.1.3) #3289
Copy link
Copy link
Open
Description
Summary
When generating .docx files using [email protected], the documents open perfectly in Neat Office and LibreOffice,
but fail to open in Microsoft Word Online and sometimes in desktop Word (Windows) with the error:
"We're sorry. We can't open this document because of an error in its contents."
Downgrading to [email protected] makes the exact same code and document structure work perfectly everywhere.
Environment
- Node.js: v18.x / v20.x
- OS: Windows
- docx version: 9.5.1
- Also tested on: 8.1.3 (works fine)
Reproduction
Minimal example:
const { Document, Packer, Paragraph, TextRun, Footer, AlignmentType, PageNumber } = require("docx");
const doc = new Document({
sections: [{
properties: {},
headers: {
default: new Footer({
children: [
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [new TextRun({ children: ["Page ", PageNumber.CURRENT] })],
}),
],
}),
},
children: [new Paragraph("Hello world")],
}],
});
Packer.toBuffer(doc).then(buffer => require("fs").writeFileSync("test.docx", buffer));
Result
✅ Works fine in Neat Office / LibreOffice.
❌ Word Online shows "Error in contents".
❌ Word Desktop prompts to repair.
Expected
Should open in all versions of Microsoft Word.enex
Metadata
Metadata
Assignees
Labels
No labels