2018-08-21 02:46:21 +01:00
|
|
|
// Footnotes
|
|
|
|
// Import from 'docx' rather than '../build' if you install from npm
|
|
|
|
import * as fs from "fs";
|
2019-11-23 02:26:59 +00:00
|
|
|
import { Document, FootnoteReferenceRun, Packer, Paragraph, TextRun } from "../build";
|
2018-08-21 02:46:21 +01:00
|
|
|
|
2019-12-03 23:04:48 +00:00
|
|
|
const doc = new Document({
|
2020-01-01 20:22:42 +00:00
|
|
|
footnotes: {
|
|
|
|
1: { children: [new Paragraph("Foo"), new Paragraph("Bar")] },
|
|
|
|
2: { children: [new Paragraph("Test")] },
|
|
|
|
3: { children: [new Paragraph("My amazing reference")] },
|
|
|
|
4: { children: [new Paragraph("Foo1")] },
|
|
|
|
5: { children: [new Paragraph("Test1")] },
|
|
|
|
6: { children: [new Paragraph("My amazing reference1")] },
|
|
|
|
},
|
2019-12-03 23:04:48 +00:00
|
|
|
});
|
2018-08-21 02:46:21 +01:00
|
|
|
|
2019-07-31 08:48:02 +01:00
|
|
|
doc.addSection({
|
2019-10-18 13:33:47 +02:00
|
|
|
children: [
|
|
|
|
new Paragraph({
|
2019-11-21 01:02:46 +00:00
|
|
|
children: [
|
|
|
|
new TextRun({
|
|
|
|
children: ["Hello", new FootnoteReferenceRun(1)],
|
|
|
|
}),
|
|
|
|
new TextRun({
|
|
|
|
children: [" World!", new FootnoteReferenceRun(2)],
|
|
|
|
}),
|
|
|
|
],
|
2019-10-18 13:33:47 +02:00
|
|
|
}),
|
2019-11-23 02:26:59 +00:00
|
|
|
new Paragraph({
|
|
|
|
children: [new TextRun("Hello World"), new FootnoteReferenceRun(3)],
|
|
|
|
}),
|
2019-10-18 13:33:47 +02:00
|
|
|
],
|
2019-07-31 08:48:02 +01:00
|
|
|
});
|
2018-08-21 02:46:21 +01:00
|
|
|
|
2019-12-03 23:04:48 +00:00
|
|
|
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)],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|
2018-08-21 02:46:21 +01:00
|
|
|
|
2019-08-07 22:12:14 +01:00
|
|
|
Packer.toBuffer(doc).then((buffer) => {
|
2018-08-21 02:46:21 +01:00
|
|
|
fs.writeFileSync("My Document.docx", buffer);
|
|
|
|
});
|