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")] },
|
|
|
|
},
|
2021-03-19 20:53:56 +00:00
|
|
|
sections: [
|
|
|
|
{
|
2019-11-21 01:02:46 +00:00
|
|
|
children: [
|
2021-03-19 20:53:56 +00:00
|
|
|
new Paragraph({
|
|
|
|
children: [
|
|
|
|
new TextRun({
|
2022-07-12 17:29:09 +01:00
|
|
|
children: ["Hello"],
|
2021-03-19 20:53:56 +00:00
|
|
|
}),
|
2022-07-12 17:29:09 +01:00
|
|
|
new FootnoteReferenceRun(1),
|
2021-03-19 20:53:56 +00:00
|
|
|
new TextRun({
|
2022-07-12 17:29:09 +01:00
|
|
|
children: [" World!"],
|
|
|
|
}),
|
|
|
|
new FootnoteReferenceRun(2),
|
|
|
|
new TextRun({
|
|
|
|
children: [" GitHub!"],
|
2021-03-19 20:53:56 +00:00
|
|
|
}),
|
|
|
|
],
|
2019-11-21 01:02:46 +00:00
|
|
|
}),
|
2021-03-19 20:53:56 +00:00
|
|
|
new Paragraph({
|
|
|
|
children: [new TextRun("Hello World"), new FootnoteReferenceRun(3)],
|
2019-11-21 01:02:46 +00:00
|
|
|
}),
|
|
|
|
],
|
2021-03-19 20:53:56 +00:00
|
|
|
},
|
|
|
|
{
|
2019-12-03 23:04:48 +00:00
|
|
|
children: [
|
2021-03-19 20:53:56 +00:00
|
|
|
new Paragraph({
|
|
|
|
children: [
|
|
|
|
new TextRun({
|
2022-07-12 17:29:09 +01:00
|
|
|
children: ["Hello"],
|
2021-03-19 20:53:56 +00:00
|
|
|
}),
|
2022-07-12 17:29:09 +01:00
|
|
|
new FootnoteReferenceRun(4),
|
2021-03-19 20:53:56 +00:00
|
|
|
new TextRun({
|
2022-07-12 17:29:09 +01:00
|
|
|
children: [" World!"],
|
2021-03-19 20:53:56 +00:00
|
|
|
}),
|
2022-07-12 17:29:09 +01:00
|
|
|
new FootnoteReferenceRun(5),
|
2021-03-19 20:53:56 +00:00
|
|
|
],
|
2019-12-03 23:04:48 +00:00
|
|
|
}),
|
2021-03-19 20:53:56 +00:00
|
|
|
new Paragraph({
|
2022-07-12 17:29:09 +01:00
|
|
|
children: [new TextRun("Hello World Again"), new FootnoteReferenceRun(6)],
|
2019-12-03 23:04:48 +00:00
|
|
|
}),
|
|
|
|
],
|
2021-03-19 20:53:56 +00:00
|
|
|
},
|
2019-12-03 23:04:48 +00:00
|
|
|
],
|
|
|
|
});
|
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);
|
|
|
|
});
|