Make create footnote declarative

This commit is contained in:
Dolan
2019-12-03 23:04:48 +00:00
parent 2b0953bb19
commit 2bece0bb61
4 changed files with 216 additions and 13 deletions

View File

@ -3,7 +3,16 @@
import * as fs from "fs";
import { Document, FootnoteReferenceRun, Packer, Paragraph, TextRun } from "../build";
const doc = new Document();
const doc = new Document({
footnotes: [
new Paragraph("Foo"),
new Paragraph("Test"),
new Paragraph("My amazing reference"),
new Paragraph("Foo1"),
new Paragraph("Test1"),
new Paragraph("My amazing reference1"),
],
});
doc.addSection({
children: [
@ -23,9 +32,23 @@ doc.addSection({
],
});
doc.createFootnote(new Paragraph("Foo"));
doc.createFootnote(new Paragraph("Test"));
doc.createFootnote(new Paragraph("My amazing reference"));
doc.addSection({
children: [
new Paragraph({
children: [
new TextRun({
children: ["Hello", new FootnoteReferenceRun(4)],
}),
new TextRun({
children: [" World!", new FootnoteReferenceRun(5)],
}),
],
}),
new Paragraph({
children: [new TextRun("Hello World"), new FootnoteReferenceRun(6)],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);