docx icon indicating copy to clipboard operation
docx copied to clipboard

doesn't create filled TOC in downloaded docx

Open lacera opened this issue 6 years ago • 6 comments

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>
`

lacera avatar Aug 14 '19 21:08 lacera

Ah it does work for me, but you need to press that button:

image

This is a known issue, but I'm not sure how to fix it.

Then it displays like normal:

image

Check out demo 28: https://github.com/dolanmiu/docx/blob/master/demo/28-table-of-contents.ts

dolanmiu avatar Aug 14 '19 23:08 dolanmiu

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 :) )

lacera avatar Aug 15 '19 06:08 lacera

If you can find a way to fix it, please make a PR!

dolanmiu avatar Aug 15 '19 23:08 dolanmiu

Any update on this enhancement

vijayarun avatar Nov 06 '20 07:11 vijayarun

Any new updates for this issue...???

Veeresh870 avatar Nov 07 '20 15:11 Veeresh870

I would love to have this fixed also, but I suspect it is very hard.

kalda341 avatar Jul 27 '21 03:07 kalda341

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

dolanmiu avatar Jan 18 '23 04:01 dolanmiu