diff --git a/demo/3-numbering-and-bullet-points.ts b/demo/3-numbering-and-bullet-points.ts index 3e6aaa644d..9242fd59fe 100644 --- a/demo/3-numbering-and-bullet-points.ts +++ b/demo/3-numbering-and-bullet-points.ts @@ -1,7 +1,7 @@ // Numbering and bullet points example // Import from 'docx' rather than '../build' if you install from npm import * as fs from "fs"; -import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build"; +import { AlignmentType, convertInchesToTwip, Document, Footer, Header, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build"; const doc = new Document({ numbering: { @@ -119,6 +119,46 @@ const doc = new Document({ }, sections: [ { + headers: { + default: new Header({ + children: [ + new Paragraph({ + text: "Hey you", + numbering: { + reference: "my-crazy-numbering", + level: 0, + }, + }), + new Paragraph({ + text: "What's up fam", + numbering: { + reference: "my-crazy-numbering", + level: 1, + }, + }), + ], + }), + }, + footers: { + default: new Footer({ + children: [ + new Paragraph({ + text: "Hey you", + numbering: { + reference: "my-crazy-numbering", + level: 0, + }, + }), + new Paragraph({ + text: "What's up fam", + numbering: { + reference: "my-crazy-numbering", + level: 1, + }, + }), + ], + }), + }, children: [ new Paragraph({ text: "Hey you", diff --git a/src/export/packer/next-compiler.ts b/src/export/packer/next-compiler.ts index 2afe0fde98..4d7ce6ffd2 100644 --- a/src/export/packer/next-compiler.ts +++ b/src/export/packer/next-compiler.ts @@ -279,8 +279,10 @@ export class Compiler { // TODO: 0 needs to be changed when headers get relationships of their own const xmlData = this.imageReplacer.replace(tempXmlData, mediaDatas, 0); + const referenedXmlData = this.numberingReplacer.replace(xmlData, file.Numbering.ConcreteNumbering); + return { - data: xmlData, + data: referenedXmlData, path: `word/header${index + 1}.xml`, }; }), @@ -301,8 +303,10 @@ export class Compiler { // TODO: 0 needs to be changed when headers get relationships of their own const xmlData = this.imageReplacer.replace(tempXmlData, mediaDatas, 0); + const referenedXmlData = this.numberingReplacer.replace(xmlData, file.Numbering.ConcreteNumbering); + return { - data: xmlData, + data: referenedXmlData, path: `word/footer${index + 1}.xml`, }; }),