diff --git a/demo/demo8.js b/demo/demo8.js index a12a4decd0..90213955f2 100644 --- a/demo/demo8.js +++ b/demo/demo8.js @@ -1,15 +1,15 @@ const docx = require('../build'); -var doc = new docx.Document(); +var doc = new docx.Document(undefined,{differentFirstPageHeader:true}); doc.createParagraph("First Page").pageBreak() doc.createParagraph("Second Page"); - -var pageoneheader = new docx.Paragraph("Running head: My Title").maxRightTabStop(); var tab = new docx.TextRun().tab() var pageNumber = new docx.TextRun().pageNumber() +var pageoneheader = new docx.Paragraph("Running head: My Title").maxRightTabStop(); + pageoneheader.addRun(tab); pageoneheader.addRun(pageNumber); doc.firstPageHeader.addParagraph(pageoneheader); diff --git a/src/export/packer/compiler.ts b/src/export/packer/compiler.ts index f267b991bc..75357219bc 100644 --- a/src/export/packer/compiler.ts +++ b/src/export/packer/compiler.ts @@ -68,14 +68,10 @@ export class Compiler { name: "word/header1.xml", }); - - this.archive.append(xmlHeader2, { name: "word/header2.xml", }); - - this.archive.append(xmlFooter, { name: "word/footer1.xml", }); diff --git a/src/file/document/body/section-properties/section-properties.ts b/src/file/document/body/section-properties/section-properties.ts index 5c06ee8631..711d580962 100644 --- a/src/file/document/body/section-properties/section-properties.ts +++ b/src/file/document/body/section-properties/section-properties.ts @@ -31,6 +31,7 @@ export class SectionProperties extends XmlComponent { space: 708, linePitch: 360, orientation: "portrait", + differentFirstPageHeader: false, }; const mergedOptions = { @@ -53,8 +54,12 @@ export class SectionProperties extends XmlComponent { this.root.push(new Columns(mergedOptions.space)); this.root.push(new DocumentGrid(mergedOptions.linePitch)); this.root.push(new HeaderReference("default",3)); - this.root.push(new HeaderReference("first",5)); - this.root.push(new TitlePage()); + + if (mergedOptions.differentFirstPageHeader) { + this.root.push(new HeaderReference("first",5)); + this.root.push(new TitlePage()); + } + this.root.push(new FooterReference()); } }