Section WIP

This commit is contained in:
Dolan
2019-07-07 03:54:29 +01:00
parent f33d6da65a
commit 58346a8937
3 changed files with 66 additions and 43 deletions

View File

@ -15,68 +15,77 @@ const footer = doc.createFooter();
footer.add(new Paragraph("Footer on another page"));
doc.addSection({
headers: {
default: header,
properties: {
headers: {
default: header,
},
footers: {
default: footer,
},
pageNumberStart: 1,
pageNumberFormatType: PageNumberFormat.DECIMAL,
},
footers: {
default: footer,
},
pageNumberStart: 1,
pageNumberFormatType: PageNumberFormat.DECIMAL,
children: [new Paragraph("hello")],
});
doc.add(new Paragraph("hello"));
doc.addSection({
headers: {
default: header,
properties: {
headers: {
default: header,
},
footers: {
default: footer,
},
pageNumberStart: 1,
pageNumberFormatType: PageNumberFormat.DECIMAL,
orientation: PageOrientation.LANDSCAPE,
},
footers: {
default: footer,
},
pageNumberStart: 1,
pageNumberFormatType: PageNumberFormat.DECIMAL,
orientation: PageOrientation.LANDSCAPE,
children: [new Paragraph("hello in landscape")],
});
doc.add(new Paragraph("hello in landscape"));
const header2 = doc.createHeader();
const pageNumber = new TextRun("Page number: ").pageNumber();
header2.add(new Paragraph({}).addRun(pageNumber));
doc.addSection({
headers: {
default: header2,
properties: {
headers: {
default: header2,
},
orientation: PageOrientation.PORTRAIT,
},
orientation: PageOrientation.PORTRAIT,
children: [new Paragraph("Page number in the header must be 2, because it continues from the previous section.")],
});
doc.add(new Paragraph("Page number in the header must be 2, because it continues from the previous section."));
doc.addSection({
headers: {
default: header2,
properties: {
headers: {
default: header2,
},
pageNumberFormatType: PageNumberFormat.UPPER_ROMAN,
orientation: PageOrientation.PORTRAIT,
},
pageNumberFormatType: PageNumberFormat.UPPER_ROMAN,
orientation: PageOrientation.PORTRAIT,
children: [
new Paragraph(
"Page number in the header must be III, because it continues from the previous section, but is defined as upper roman.",
),
],
});
doc.add(new Paragraph(
"Page number in the header must be III, because it continues from the previous section, but is defined as upper roman.",
));
doc.addSection({
headers: {
default: header2,
properties: {
headers: {
default: header2,
},
pageNumberFormatType: PageNumberFormat.DECIMAL,
pageNumberStart: 25,
orientation: PageOrientation.PORTRAIT,
},
pageNumberFormatType: PageNumberFormat.DECIMAL,
pageNumberStart: 25,
orientation: PageOrientation.PORTRAIT,
children: [
new Paragraph("Page number in the header must be 25, because it is defined to start at 25 and to be decimal in this section."),
],
});
doc.add(new Paragraph("Page number in the header must be 25, because it is defined to start at 25 and to be decimal in this section."));
const packer = new Packer();
packer.toBuffer(doc).then((buffer) => {