Change to new header API

This commit is contained in:
Dolan
2018-10-05 01:33:17 +01:00
parent 3508fd97ec
commit 97f76fb62c
4 changed files with 215 additions and 100 deletions

View File

@ -1,7 +1,7 @@
// Multiple sections and headers
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, FooterReferenceType, HeaderReferenceType, Packer, PageNumberFormat, PageOrientation, Paragraph } from "../build";
import { Document, Packer, PageNumberFormat, PageOrientation, Paragraph } from "../build";
const doc = new Document();
@ -15,8 +15,12 @@ const footer = doc.createFooter();
footer.createParagraph("Footer on another page");
doc.addSection({
headers: [{headerId: header.Header.ReferenceId, headerType: HeaderReferenceType.FIRST}],
footers: [{footerId: footer.Footer.ReferenceId, footerType: FooterReferenceType.FIRST}],
headers: {
default: header,
},
footers: {
default: footer,
},
pageNumberStart: 1,
pageNumberFormatType: PageNumberFormat.DECIMAL,
});
@ -24,8 +28,12 @@ doc.addSection({
doc.createParagraph("hello");
doc.addSection({
headers: [{headerId: header.Header.ReferenceId, headerType: HeaderReferenceType.FIRST}],
footers: [{footerId: footer.Footer.ReferenceId, footerType: FooterReferenceType.FIRST}],
headers: {
default: header,
},
footers: {
default: footer,
},
pageNumberStart: 1,
pageNumberFormatType: PageNumberFormat.DECIMAL,
orientation: PageOrientation.LANDSCAPE,