Add, Read, and Delete Word Footnotes and Endnotes from Java
Automated Java document pipelines can now handle footnotes and endnotes end-to-end, which matters for report generators, thesis tools, and any software that creates or audits Word files with academic annotations.
Spire.Doc's Java API gives developers direct control over Word footnotes and endnotes: add them, read them, and delete them. Adding a footnote is a two-step process: locate the target text with Document.findString(), then insert a Footnote object after that TextRange via Paragraph.appendFootnote() and getChildObjects().insert(). The same appendFootnote() call creates an endnote when passed FootnoteType.Endnote, though the default position is at the paragraph's end rather than after a keyword.
Reading existing notes uses Document.getFootnotes() and Document.getEndnotes(), each returning a list of Footnote objects whose TextBody holds paragraphs. Inserting a footnote inside a document's body doesn't require touching the footer; Word's footnotes are separate from page footers. Deletion works by removing the Footnote object from its owner paragraph's child objects, iterating backward to avoid index shifts.
The article also flags positioning details: the API places markers at paragraph end by default, so precise placement after a keyword demands find-and-insert logic, and note numbering or location may depend on Word's document settings, not just the code.
The library unifies footnotes and endnotes into a single Footnote class distinguished by an enum, which keeps the API surface small and lets developers build one code path for both.
appendFootnote()'s default behavior places the marker at the paragraph end, so precise placement after a keyword requires extra find-and-insert steps, a reminder that document object placement is not always intuitive.
The warning that endnote and footnote positions depend on Word's document settings means automation must account for layout rules beyond the API's simple insertion to produce correct output.