Mandatory Sections

This commit is contained in:
Dolan Miu
2019-07-31 08:48:02 +01:00
parent bf80311ef7
commit ac5b15d0e3
63 changed files with 1194 additions and 1588 deletions

View File

@ -18,39 +18,40 @@ doc.Styles.createParagraphStyle("MySpectacularStyle", "My Spectacular Style")
// Let's define the properties for generate a TOC for heading 1-5 and MySpectacularStyle,
// making the entries be hyperlinks for the paragraph
const toc = new TableOfContents("Summary", {
hyperlink: true,
headingStyleRange: "1-5",
stylesWithLevels: [new StyleLevel("MySpectacularStyle", 1)],
doc.addSection({
children: [
new TableOfContents("Summary", {
hyperlink: true,
headingStyleRange: "1-5",
stylesWithLevels: [new StyleLevel("MySpectacularStyle", 1)],
}),
new Paragraph({
text: "Header #1",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}),
new Paragraph("I'm a little text very nicely written.'"),
new Paragraph({
text: "Header #2",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}),
new Paragraph("I'm a other text very nicely written.'"),
new Paragraph({
text: "Header #2.1",
heading: HeadingLevel.HEADING_2,
}),
new Paragraph("I'm a another text very nicely written.'"),
new Paragraph({
text: "My Spectacular Style #1",
style: "MySpectacularStyle",
pageBreakBefore: true,
}),
],
});
doc.addTableOfContents(toc);
doc.add(new Paragraph({
text: "Header #1",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}));
doc.add(new Paragraph("I'm a little text very nicely written.'"));
doc.add(new Paragraph({
text: "Header #2",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}));
doc.add(new Paragraph("I'm a other text very nicely written.'"));
doc.add(new Paragraph({
text: "Header #2.1",
heading: HeadingLevel.HEADING_2,
}));
doc.add(new Paragraph("I'm a another text very nicely written.'"));
doc.add(new Paragraph({
text: "My Spectacular Style #1",
style: "MySpectacularStyle",
pageBreakBefore: true,
}));
const packer = new Packer();
packer.toBuffer(doc).then((buffer) => {