diff --git a/src/file/paragraph/run/page-number.ts b/src/file/paragraph/run/page-number.ts index 4ae0eaafd7..2fdc44e32b 100644 --- a/src/file/paragraph/run/page-number.ts +++ b/src/file/paragraph/run/page-number.ts @@ -12,3 +12,11 @@ export class Page extends XmlComponent { this.root.push("PAGE"); } } + +export class NumberOfPages extends XmlComponent { + constructor() { + super("w:instrText"); + this.root.push(new TextAttributes({ space: SpaceType.PRESERVE })); + this.root.push("NUMPAGES"); + } +} diff --git a/src/file/paragraph/run/run.ts b/src/file/paragraph/run/run.ts index c03ed8d78e..32777cd31d 100644 --- a/src/file/paragraph/run/run.ts +++ b/src/file/paragraph/run/run.ts @@ -14,7 +14,7 @@ import { SizeComplexScript, Strike, } from "./formatting"; -import { Page } from "./page-number"; +import { NumberOfPages, Page } from "./page-number"; import { RunProperties } from "./properties"; import { RunFonts } from "./run-fonts"; import { SubScript, SuperScript } from "./script"; @@ -84,6 +84,14 @@ export class Run extends XmlComponent { return this; } + public numberOfTotalPages(): Run { + this.root.push(new Begin()); + this.root.push(new NumberOfPages()); + this.root.push(new Separate()); + this.root.push(new End()); + return this; + } + public smallCaps(): Run { this.properties.push(new SmallCaps()); return this;