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:

For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"TestFile.docx");
System::SharedPtr<DocumentBuilder> builder = System::MakeObject<DocumentBuilder>(doc);
builder->Write(u"Some text");
builder->InsertFootnote(FootnoteType::Endnote, u"Eootnote text.");
System::SharedPtr<EndnoteOptions> option = doc->get_EndnoteOptions();
option->set_RestartRule(FootnoteNumberingRule::RestartPage);
option->set_Position(EndnotePosition::EndOfSection);
System::String outputPath = outputDataDir + u"WorkingWithFootnote.SetEndnoteOptions.docx";
// Save the document to disk.
doc->Save(outputPath);

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:

For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"TestFile.docx");
//Specify the number of columns with which the footnotes area is formatted.
doc->get_FootnoteOptions()->set_Columns(3);
System::String outputPath = outputDataDir + u"WorkingWithFootnote.SetFootNoteColumns.docx";
// Save the document to disk.
doc->Save(outputPath);

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:

For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"TestFile.docx");
//Set footnote and endnode position.
doc->get_FootnoteOptions()->set_Position(FootnotePosition::BeneathText);
doc->get_EndnoteOptions()->set_Position(EndnotePosition::EndOfSection);
System::String outputPath = outputDataDir + u"WorkingWithFootnote.SetFootnoteAndEndNotePosition.docx";
// Save the document to disk.
doc->Save(outputPath);