DOCX
References
Table of contents, footnotes, endnotes, and bibliography
Table of Contents
Insert a TOC field that Word applications can update:
{
"sections": [
{
"children": [
{ "paragraph": { "heading": "Heading1", "children": ["Table of Contents"] } },
{ "toc": { "alias": "Table of Contents", "hyperlink": true, "headingStyleRange": "1-3" } }
]
}
]
}
import { generateDocument } from "@office-open/docx";
await generateDocument({
sections: [
{
children: [
{ paragraph: { heading: "Heading1", children: ["Table of Contents"] } },
{ toc: { alias: "Table of Contents", hyperlink: true, headingStyleRange: "1-3" } },
],
},
],
});
Footnotes
Add footnotes at the bottom of pages:
{
"footnotes": {
"1": { "children": ["This is the first footnote."] },
"2": { "children": ["This is the second footnote."] }
},
"sections": [
{
"children": [
{
"paragraph": {
"children": [
"A statement with a footnote",
{ "footnoteReference": 1 },
" and another",
{ "footnoteReference": 2 },
"."
]
}
}
]
}
]
}
import { generateDocument } from "@office-open/docx";
await generateDocument({
footnotes: {
1: { children: [{ paragraph: { children: ["This is the first footnote."] } }] },
2: { children: [{ paragraph: { children: ["This is the second footnote."] } }] },
},
sections: [
{
children: [
{
paragraph: {
children: [
"A statement with a footnote",
{ footnoteReference: 1 },
" and another",
{ footnoteReference: 2 },
".",
],
},
},
],
},
],
});
Endnotes
Endnotes appear at the end of the document or section:
{
"endnotes": {
"1": { "children": ["This is an endnote."] }
},
"sections": [
{
"children": [
{ "paragraph": { "children": ["Text with an endnote", { "endnoteReference": 1 }] } }
]
}
]
}
import { generateDocument } from "@office-open/docx";
await generateDocument({
endnotes: {
1: { children: [{ paragraph: { children: ["This is an endnote."] } }] },
},
sections: [
{
children: [
{
paragraph: {
children: ["Text with an endnote", { endnoteReference: 1 }],
},
},
],
},
],
});
Bibliography
Add a bibliography section for citations:
import { generateDocument } from "@office-open/docx";
// Bibliography entries are typically defined via XML sources
// and referenced through citation fields in the document