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 a footnote or endnote in a 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 a 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 can I change the numbering format of footnotes or endnotes?
    A: Use the FootnoteOptions::set_NumberStyle or EndnoteOptions::set_NumberStyle property on the document’s FootnoteOptions/EndnoteOptions object. For example:

    System::SharedPtr<Aspose::Words::Notes::FootnoteOptions> footnoteOpts = doc->get_FootnoteOptions();
    footnoteOpts->set_NumberStyle(Aspose::Words::Notes::NumberStyle::UpperRoman);
    
  2. Q: How can I retrieve all footnotes or endnotes from a document?
    A: The document provides get_Footnotes() and get_Endnotes() collections. Iterate over them to access each note’s properties, such as its text:

    for (auto footnote : System::IterateOver(doc->get_Footnotes()))
    {
        System::String text = footnote->GetText();
        // Process text...
    }
    
  3. Q: How can I detect whether a document contains any footnotes or endnotes?
    A: Check the Count property of the respective collections. If the count is greater than zero, the document contains those notes:

    bool hasFootnotes = doc->get_Footnotes()->get_Count() > 0;
    bool hasEndnotes  = doc->get_Endnotes()->get_Count() > 0;
    
  4. Q: Can I convert an existing endnote to a footnote (or vice‑versa) after it has been inserted?
    A: Aspose.Words does not provide a direct conversion method. Remove the original note using Remove() and re‑insert a new note of the desired type with DocumentBuilder::InsertFootnote, specifying NoteType::Footnote or NoteType::Endnote.

    // Remove existing endnote
    endnote->Remove();
    
    // Insert a footnote at the same location
    System::SharedPtr<Aspose::Words::DocumentBuilder> builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
    builder->MoveTo(endnote->get_Paragraph());
    builder->InsertFootnote(Aspose::Words::Notes::NoteType::Footnote, Aspose::Words::Notes::FootnoteType::Normal, System::String(u"New footnote text"));