Working with Footnote and Endnote

Aspose.Words also provides some classes, methods and properties for working with footnotes and endnotes.

Insert Endnote and Set Numbering Options

If you want to insert footnote or endnote into Word document, please use the InsertFootnote method. This method inserts a footnote or endnote into the document.

EndnoteOptions and FootnoteOptions classes represent numbering options for footnote and endnote.

The following code example shows how to insert endnote into the document and set its numbering options:

Set Number of Footnote Layout Columns

You can set the number of footnote layout columns using the Columns property. If this property has the value of 0, the footnotes area is formatted with a number of columns based on the number of columns on the displayed page.

The following code example shows how to set the number of columns for footnote layout:

Set the Position of Footnote and EndNote

The footnote position can be at the bottom of each page or beneath the text on each page. The endnote position can be at the end of the section or at the end of the document.

The following code example shows how to set the position of footnote and endnote:


FAQ

  1. Q: How do I insert a footnote or an endnote with DocumentBuilder?
    A: Use the DocumentBuilder.InsertFootnote method: pass the FootnoteType enumeration value (FootnoteType.Footnote or FootnoteType.Endnote) and the note text. The method returns the inserted Footnote object.

    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
    // Insert a footnote
    Footnote footnote = builder.InsertFootnote(FootnoteType.Footnote, "This is a footnote.");
    // Insert an endnote
    Footnote endnote = builder.InsertFootnote(FootnoteType.Endnote, "This is an endnote.");
    
  2. Q: How can I change the numbering style of footnotes or endnotes?
    A: Modify the NumberStyle property of FootnoteOptions or EndnoteOptions on the Document object. Supported styles include Arabic, UppercaseRoman, LowercaseRoman, UppercaseLetter, and LowercaseLetter.

    doc.FootnoteOptions.NumberStyle = NumberStyle.UppercaseRoman;
    doc.EndnoteOptions.NumberStyle = NumberStyle.LowercaseLetter;
    
  3. Q: What property controls the number of columns used for footnote layout?
    A: The FootnoteOptions.Columns property defines how many columns the footnote area uses. Setting it to 0 lets Word decide based on the page layout.

    doc.FootnoteOptions.Columns = 2; // Two‑column footnote area
    
  4. Q: How do I set where footnotes and endnotes appear in the document?
    A: Use the FootnoteOptions.Position and EndnoteOptions.Position properties. For footnotes you can choose FootnotePosition.BottomOfPage or FootnotePosition.BeneathText. For endnotes you can choose EndnotePosition.EndOfSection or EndnotePosition.EndOfDocument.

    doc.FootnoteOptions.Position = FootnotePosition.BottomOfPage;
    doc.EndnoteOptions.Position = EndnotePosition.EndOfDocument;
    
  5. Q: Can I convert an existing footnote to an endnote (or vice‑versa) without recreating it?
    A: Not directly: Footnote.FootnoteType is read-only. Insert a note of the other type at the same position with the same text, then remove the original note. The new note gets the plain text only; formatting inside the original note is not copied.

    // Convert the first footnote to an endnote
    Footnote footnote = (Footnote)doc.GetChild(NodeType.Footnote, 0, true);
    DocumentBuilder builder = new DocumentBuilder(doc);
    builder.MoveTo(footnote);
    builder.InsertFootnote(FootnoteType.Endnote, footnote.ToString(SaveFormat.Text).Trim());
    footnote.Remove();