docx
docx copied to clipboard
doesn't create filled TOC in downloaded docx
Hi! Help, please. This simple example (copied from codepen.io HTML block) doesn't create filled TOC in downloaded docx and i have no ideas, why :( `
<script>
function generate() {
const doc = new Document();
doc.addSection({
children: [
new TableOfContents("Summary", {
hyperlink: true,
headingStyleRange: "1-5",
}),
new Paragraph({
text: "Header #1",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}),
]
});
Packer.toBlob(doc).then(blob => {
console.log(blob);
saveAs(blob, "example.docx");
console.log("Document created successfully");
});
}
</script>
`
Ah it does work for me, but you need to press that button:

This is a known issue, but I'm not sure how to fix it.
Then it displays like normal:

Check out demo 28: https://github.com/dolanmiu/docx/blob/master/demo/28-table-of-contents.ts
heh, i have two ways: open it in *nix LibreOffice (no result with broken TOC but other docx with filled TOC open with filled TOC) and open it in docs.google.com (no result too... but there i may update TOC and see it but this it dances with tambourine :) )
If you can find a way to fix it, please make a PR!
Any update on this enhancement
Any new updates for this issue...???
I would love to have this fixed also, but I suspect it is very hard.
I do not think it is possible actually, and thats by design. OOXML does not know about the concept of pages. I have wrote an explanation on the related issue.
Related issue:
https://github.com/dolanmiu/docx/issues/1212