Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doesn't create filled TOC in downloaded docx #380

Closed
lacera opened this issue Aug 14, 2019 · 7 comments
Closed

doesn't create filled TOC in downloaded docx #380

lacera opened this issue Aug 14, 2019 · 7 comments

Comments

@lacera
Copy link

lacera commented Aug 14, 2019

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 src="https://unpkg.com/docx@5.0.0-rc5/build/index.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.js"></script> Click to generate document
<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>
`
@dolanmiu
Copy link
Owner

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

@lacera
Copy link
Author

lacera commented Aug 15, 2019

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

@dolanmiu
Copy link
Owner

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

@vijayarun
Copy link

Any update on this enhancement

@Veeresh870
Copy link

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

@kalda341
Copy link
Contributor

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

@dolanmiu
Copy link
Owner

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:

#1212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants