question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing use of "NumberingReplacer" at header&footer

See original GitHub issue

Salute 😃

My recent finding is that the “NumberingReplacer” is run for the document, but it forgotten for Header/Footer stage in Packer (next-compiler.ts). Word does allow including numbering into Header/Footer. Altho if you try to use numbering there, the w:numId is incorrect.

https://github.com/dolanmiu/docx/blob/9b840c0d63227818209036524fbc2c9fede145e7/src/export/packer/next-compiler.ts#L41

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dolanmiucommented, Jun 19, 2022

Sure! I will make a release soon too

Maybe or maybe not after merge of: https://github.com/dolanmiu/docx/pull/1448

Depending if it works on time

0reactions
anti-the-socialcommented, Jun 30, 2022

Good job, all works 😃

p.s. found out that my reproducing code in previous comments was wrong (I probably copied wrong content)

Proper code for testing
const { Document, Packer, Paragraph, NumberFormat, Header} = require('docx');

const doc = new Document({
  numbering:{
    config:[{
      reference: 'ref1',
      levels: [
        {
          level: 0,
          format: NumberFormat.DECIMAL,
          text: '%1)'
        },
        {
          level: 1,
          format: NumberFormat.LOWER_LETTER,
          text: '%2)'
        }
      ],
    }]
  },
  sections: [{
    headers: {
      default: new Header({
        children: [
          new Paragraph({
            text: "some random question",
            numbering : {
              reference: 'ref1',
              level: 0,
            }
          }),
          new Paragraph({
            text: "option 1",
            numbering : {
              reference: 'ref1',
              level: 1,
            }
          }),
          new Paragraph({
            text: "option 2",
            numbering : {
              reference: 'ref1',
              level: 1,
            }
          }),
          new Paragraph({
            text: "Some other random question",
            numbering : {
              reference: 'ref1',
              level: 0,
            }
          }),
        ],
      }),
    },
    children: [
      new Paragraph({
        text: "some random question",
        numbering : {
          reference: 'ref1',
          level: 0,
        }
      }),
      new Paragraph({
        text: "option 1",
        numbering : {
          reference: 'ref1',
          level: 1,
        }
      }),
      new Paragraph({
        text: "option 2",
        numbering : {
          reference: 'ref1',
          level: 1,
        }
      }),
      new Paragraph({
        text: "option 3",
        numbering : {
          reference: 'ref1',
          level: 0,
        }
      }),
      new Paragraph({
        text: "Some other random question",
        numbering : {
          reference: 'ref1',
          level: 0,
        }
      }),
    ],
  }]
});

// Used to export the file into a .docx file
Packer.toBuffer(doc).then((buffer) => {
    fs.writeFileSync("list_in_header.docx", buffer);
});```
<details>
Read more comments on GitHub >

github_iconTop Results From Across the Web

iTextSharp is missing HeaderFooter class - Stack Overflow
I've used Reflector to see if I can find out whereabouts the class is and its missing?! Does anyone know what has happened...
Read more >
Document Inspector - Missing Header, Footer Option
Hi, I have using Document Inspector option of Microsoft Word 2016 for quite a while. Suddenly, the content "Header, Footer" vanished from ...
Read more >
I Can't Insert a Page Number in Word 2007 - 2021 (365)!
Long-term solution, see below. Problem - Header/Footer Options missing: The problem this page covers also has been described as follows: I want ...
Read more >
Header and Footer or Top / Bottom margins are missing in ...
Double click when the icon appears to restore the top and bottom margins / headers & footers. For additional information on editing margins,...
Read more >
Blog Posts Missing Header Footer Title Featured Image
Hello, Today when I was editing a page with the Cornerstone Page Builder for X Theme, something happened where my blog posts' headers,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found