Added differentFirstPageHeader section property

This commit is contained in:
Tyler Bell
2018-05-17 11:45:06 -06:00
parent 7968c1efcf
commit 6c2eb882bb
3 changed files with 10 additions and 9 deletions

View File

@ -1,15 +1,15 @@
const docx = require('../build'); const docx = require('../build');
var doc = new docx.Document(); var doc = new docx.Document(undefined,{differentFirstPageHeader:true});
doc.createParagraph("First Page").pageBreak() doc.createParagraph("First Page").pageBreak()
doc.createParagraph("Second Page"); doc.createParagraph("Second Page");
var pageoneheader = new docx.Paragraph("Running head: My Title").maxRightTabStop();
var tab = new docx.TextRun().tab() var tab = new docx.TextRun().tab()
var pageNumber = new docx.TextRun().pageNumber() var pageNumber = new docx.TextRun().pageNumber()
var pageoneheader = new docx.Paragraph("Running head: My Title").maxRightTabStop();
pageoneheader.addRun(tab); pageoneheader.addRun(tab);
pageoneheader.addRun(pageNumber); pageoneheader.addRun(pageNumber);
doc.firstPageHeader.addParagraph(pageoneheader); doc.firstPageHeader.addParagraph(pageoneheader);

View File

@ -68,14 +68,10 @@ export class Compiler {
name: "word/header1.xml", name: "word/header1.xml",
}); });
this.archive.append(xmlHeader2, { this.archive.append(xmlHeader2, {
name: "word/header2.xml", name: "word/header2.xml",
}); });
this.archive.append(xmlFooter, { this.archive.append(xmlFooter, {
name: "word/footer1.xml", name: "word/footer1.xml",
}); });

View File

@ -31,6 +31,7 @@ export class SectionProperties extends XmlComponent {
space: 708, space: 708,
linePitch: 360, linePitch: 360,
orientation: "portrait", orientation: "portrait",
differentFirstPageHeader: false,
}; };
const mergedOptions = { const mergedOptions = {
@ -53,8 +54,12 @@ export class SectionProperties extends XmlComponent {
this.root.push(new Columns(mergedOptions.space)); this.root.push(new Columns(mergedOptions.space));
this.root.push(new DocumentGrid(mergedOptions.linePitch)); this.root.push(new DocumentGrid(mergedOptions.linePitch));
this.root.push(new HeaderReference("default",3)); 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()); this.root.push(new FooterReference());
} }
} }