Aspose::Words::Notes::Footnote class

Footnote class

Represents a container for text of a footnote or endnote. To learn more, visit the Working with Footnote and Endnote documentation article.

class Footnote : public InlineStory,
                 public Revisions::ITrackableNode

Methods

MethodDescription
Accept(System::SharedPtr<Aspose::Words::DocumentVisitor>) overrideAccepts a visitor.
AcceptEnd(System::SharedPtr<Aspose::Words::DocumentVisitor>) overrideAccepts a visitor for visiting the end of the footnote.
AcceptStart(System::SharedPtr<Aspose::Words::DocumentVisitor>) overrideAccepts a visitor for visiting the start of the footnote.
Footnote(const System::SharedPtr<Aspose::Words::DocumentBase> &, Aspose::Words::Notes::FootnoteType)Initializes an instance of the Footnote class.
get_ActualReferenceMark()Gets the actual text of the reference mark displayed in the document for this footnote.
get_FootnoteType() constReturns a value that specifies whether this is a footnote or endnote.
get_IsAuto() constHolds a value that specifies whether this is a auto-numbered footnote or footnote with user defined custom reference mark.
get_NodeType() const overrideReturns Footnote.
get_ReferenceMark() constGets/sets custom reference mark to be used for this footnote. Default value is empty string, meaning auto-numbered footnotes are used.
get_StoryType() overrideReturns Footnotes or Endnotes.
set_IsAuto(bool)Holds a value that specifies whether this is a auto-numbered footnote or footnote with user defined custom reference mark.
set_ReferenceMark(const System::String &)Gets/sets custom reference mark to be used for this footnote. Default value is empty string, meaning auto-numbered footnotes are used.
EnsureMinimum()If the last child is not a paragraph, creates and appends one empty paragraph.
get_FirstParagraph() overrideGets the first paragraph in the story.
get_Font()Provides access to the font formatting of the anchor character of this object.
get_IsDeleteRevision()Returns true if this object was deleted in Microsoft Word while change tracking was enabled.
get_IsInsertRevision()Returns true if this object was inserted in Microsoft Word while change tracking was enabled.
get_IsMoveFromRevision()Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled.
get_IsMoveToRevision()Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled.
get_LastParagraph() overrideGets the last paragraph in the story.
get_Paragraphs() overrideGets a collection of paragraphs that are immediate children of the story.
get_ParentParagraph()Retrieves the parent Paragraph of this node.
get_StoryType() overrideReturns the type of the story.
get_Tables() overrideGets a collection of tables that are immediate children of the story.
virtual AcceptEnd(System::SharedPtr<Aspose::Words::DocumentVisitor>)When implemented in a derived class, calls the VisitXXXEnd method of the specified document visitor.
virtual AcceptStart(System::SharedPtr<Aspose::Words::DocumentVisitor>)When implemented in a derived class, calls the VisitXXXStart method of the specified document visitor.
AppendChild(T)Adds the specified node to the end of the list of child nodes for this node.
GetChild(Aspose::Words::NodeType, int32_t, bool)Returns an Nth child node that matches the specified type.
GetChildNodes(Aspose::Words::NodeType, bool)Returns a live collection of child nodes that match the specified type.
GetEnumerator() overrideProvides support for the for each style iteration over the child nodes of this node.
GetText() overrideGets the text of this node and of all its children.
IndexOf(const System::SharedPtr<Aspose::Words::Node> &)Returns the index of the specified child node in the child node array.
InsertAfter(T, const System::SharedPtr<Aspose::Words::Node> &)Inserts the specified node immediately after the specified reference node.
InsertBefore(T, const System::SharedPtr<Aspose::Words::Node> &)Inserts the specified node immediately before the specified reference node.
PrependChild(T)Adds the specified node to the beginning of the list of child nodes for this node.
RemoveAllChildren()Removes all the child nodes of the current node.
RemoveChild(T)Removes the specified child node.
RemoveSmartTags()Removes all SmartTag descendant nodes of the current node.
SelectNodes(const System::String &)Selects a list of nodes matching the XPath expression.
SelectSingleNode(const System::String &)Selects the first Node that matches the XPath expression.
get_Count()Gets the number of immediate children of this node.
get_FirstChild() constGets the first child of the node.
get_HasChildNodes()Returns true if this node has any child nodes.
get_IsComposite() overrideReturns true as this node can have child nodes.
get_LastChild() constGets the last child of the node.
virtual Accept(System::SharedPtr<Aspose::Words::DocumentVisitor>)Accepts a visitor.
Clone(bool)Creates a duplicate of the node.
GetAncestor(Aspose::Words::NodeType)Gets the first ancestor of the specified NodeType.
virtual GetText()Gets the text of this node and of all its children.
NextPreOrder(const System::SharedPtr<Aspose::Words::Node> &)Gets next node according to the pre-order tree traversal algorithm.
static NodeTypeToString(Aspose::Words::NodeType)A utility method that converts a node type enum value into a user friendly string.
PreviousPreOrder(const System::SharedPtr<Aspose::Words::Node> &)Gets the previous node according to the pre-order tree traversal algorithm.
Remove()Removes itself from the parent.
ToString(Aspose::Words::SaveFormat)Exports the content of the node into a string in the specified format.
ToString(const System::SharedPtr<Aspose::Words::Saving::SaveOptions> &)Exports the content of the node into a string using the specified save options.
get_CustomNodeId() constSpecifies custom node identifier.
virtual get_Document() constGets the document to which this node belongs.
virtual get_IsComposite()Returns true if this node can contain other nodes.
get_NextSibling()Gets the node immediately following this node.
virtual get_NodeType() constGets the type of this node.
get_ParentNode()Gets the immediate parent of this node.
get_PreviousSibling()Gets the node immediately preceding this node.
get_Range()Returns a Range object that represents the portion of a document that is contained in this node.
set_CustomNodeId(int32_t)Specifies custom node identifier.

Remarks

The Footnote class is used to represent both footnotes and endnotes in a Word document.

Footnote is an inline-level node and can only be a child of Paragraph.

Footnote can contain Paragraph and Table child nodes.

Examples

Shows how to insert and customize footnotes.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);

// Add text, and reference it with a footnote. This footnote will place a small superscript reference
// mark after the text that it references and create an entry below the main body text at the bottom of the page.
// This entry will contain the footnote's reference mark and the reference text,
// which we will pass to the document builder's "InsertFootnote" method.
builder->Write(u"Main body text.");
System::SharedPtr<Aspose::Words::Notes::Footnote> footnote = builder->InsertFootnote(FootnoteType::Footnote, u"Footnote text.");

// If this property is set to "true", then our footnote's reference mark
// will be its index among all the section's footnotes.
// This is the first footnote, so the reference mark will be "1".
ASSERT_TRUE(footnote->get_IsAuto());

// We can move the document builder inside the footnote to edit its reference text.
builder->MoveTo(footnote->get_FirstParagraph());
builder->Write(u" More text added by a DocumentBuilder.");
builder->MoveToDocumentEnd();

ASSERT_EQ(footnote->GetText().Trim(), u"\u0002 Footnote text. More text added by a DocumentBuilder.");

builder->Write(u" More main body text.");
footnote = builder->InsertFootnote(FootnoteType::Footnote, u"Footnote text.");

// We can set a custom reference mark which the footnote will use instead of its index number.
footnote->set_ReferenceMark(u"RefMark");

ASSERT_FALSE(footnote->get_IsAuto());

// A bookmark with the "IsAuto" flag set to true will still show its real index
// even if previous bookmarks display custom reference marks, so this bookmark's reference mark will be a "3".
builder->Write(u" More main body text.");
footnote = builder->InsertFootnote(FootnoteType::Footnote, u"Footnote text.");

ASSERT_TRUE(footnote->get_IsAuto());

doc->Save(get_ArtifactsDir() + u"InlineStory.AddFootnote.docx");

See Also