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-21 01:02:46 +00:00
|
|
|
import { Document, Packer, Paragraph, TextRun, FootnoteReferenceRun } from "../build";
|
2018-08-21 02:46:21 +01:00
|
|
|
|
|
|
|
const doc = new Document();
|
|
|
|
|
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
|
|
|
}),
|
|
|
|
new Paragraph("Hello World").referenceFootnote(3),
|
|
|
|
],
|
2019-07-31 08:48:02 +01:00
|
|
|
});
|
2018-08-21 02:46:21 +01:00
|
|
|
|
2019-10-18 13:33:47 +02:00
|
|
|
doc.createFootnote(new Paragraph("Foo"));
|
2018-08-21 02:46:21 +01:00
|
|
|
doc.createFootnote(new Paragraph("Test"));
|
|
|
|
doc.createFootnote(new Paragraph("My amazing reference"));
|
|
|
|
|
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);
|
|
|
|
});
|