dolanmiu / docx

Easily generate and modify .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.

Home Page:https://docx.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Field Codes in SimpleField Formulas

mattidupre opened this issue · comments

I'm attempting to offset the Total Pages in my Header / Footer.

Tried the following (all within Header > Paragraph > TextRun):

  • new SimpleField('NUMPAGES + 1') // just renders NUMPAGES
  • new SimpleField('= NUMPAGES + 1') // !Undefined Bookmark, NUMPAGES
  • new SimpleField('= { NUMPAGES } + 1') // !Syntax Error, {
  • new SimpleField('{ = { NUMPAGES } + 1 }') // nothing rendered

Is this beyond the scope of the SimpleField class?

Yes it is beyond the scope. Finding Total pages is a Microsoft Word or Word processor feature

The .docx document (ooxml) itself is dumb, and does not know about pages, it is simply an XML file