Footnote

Footnote class

Represents a container for text of a footnote or endnote.

To learn more, visit the Working with Footnote and Endnote documentation article.

public class Footnote : InlineStory

Constructors

NameDescription
Footnote(DocumentBaseFootnoteType)Initializes an instance of the Footnote class.

Properties

NameDescription
ActualReferenceMark { get; }Gets the actual text of the reference mark displayed in the document for this footnote.
Count { get; }Gets the number of immediate children of this node.
CustomNodeId { get; set; }Specifies custom node identifier.
virtual Document { get; }Gets the document to which this node belongs.
FirstChild { get; }Gets the first child of the node.
FirstParagraph { get; }Gets the first paragraph in the story.
Font { get; }Provides access to the font formatting of the anchor character of this object.
FootnoteType { get; }Returns a value that specifies whether this is a footnote or endnote.
HasChildNodes { get; }Returns true if this node has any child nodes.
IsAuto { get; set; }Holds a value that specifies whether this is a auto-numbered footnote or footnote with user defined custom reference mark.
override IsComposite { get; }Returns true as this node can have child nodes.
IsDeleteRevision { get; }Returns true if this object was deleted in Microsoft Word while change tracking was enabled.
IsInsertRevision { get; }Returns true if this object was inserted in Microsoft Word while change tracking was enabled.
IsMoveFromRevision { get; }Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled.
IsMoveToRevision { get; }Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled.
LastChild { get; }Gets the last child of the node.
LastParagraph { get; }Gets the last paragraph in the story.
NextSibling { get; }Gets the node immediately following this node.
override NodeType { get; }Returns Footnote.
Paragraphs { get; }Gets a collection of paragraphs that are immediate children of the story.
ParentNode { get; }Gets the immediate parent of this node.
ParentParagraph { get; }Retrieves the parent Paragraph of this node.
PreviousSibling { get; }Gets the node immediately preceding this node.
Range { get; }Returns a Range object that represents the portion of a document that is contained in this node.
ReferenceMark { get; set; }Gets/sets custom reference mark to be used for this footnote. Default value is empty string (Empty), meaning auto-numbered footnotes are used.
override StoryType { get; }Returns Footnotes or Endnotes.
Tables { get; }Gets a collection of tables that are immediate children of the story.

Methods

NameDescription
override Accept(DocumentVisitor)Accepts a visitor.
override AcceptEnd(DocumentVisitor)Accepts a visitor for visiting the end of the footnote.
override AcceptStart(DocumentVisitor)Accepts a visitor for visiting the start of the footnote.
AppendChild<T>(T)Adds the specified node to the end of the list of child nodes for this node.
Clone(bool)Creates a duplicate of the node.
CreateNavigator()Creates navigator which can be used to traverse and read nodes.
EnsureMinimum()If the last child is not a paragraph, creates and appends one empty paragraph.
GetAncestor(NodeType)Gets the first ancestor of the specified NodeType.
GetAncestor(Type)Gets the first ancestor of the specified object type.
GetChild(NodeType, int, bool)Returns an Nth child node that matches the specified type.
GetChildNodes(NodeType, bool)Returns a live collection of child nodes that match the specified type.
GetEnumerator()Provides support for the for each style iteration over the child nodes of this node.
override GetText()Gets the text of this node and of all its children.
IndexOf(Node)Returns the index of the specified child node in the child node array.
InsertAfter<T>(T, Node)Inserts the specified node immediately after the specified reference node.
InsertBefore<T>(T, Node)Inserts the specified node immediately before the specified reference node.
NextPreOrder(Node)Gets next node according to the pre-order tree traversal algorithm.
PrependChild<T>(T)Adds the specified node to the beginning of the list of child nodes for this node.
PreviousPreOrder(Node)Gets the previous node according to the pre-order tree traversal algorithm.
Remove()Removes itself from the parent.
RemoveAllChildren()Removes all the child nodes of the current node.
RemoveChild<T>(T)Removes the specified child node.
RemoveSmartTags()Removes all SmartTag descendant nodes of the current node.
SelectNodes(string)Selects a list of nodes matching the XPath expression.
SelectSingleNode(string)Selects the first Node that matches the XPath expression.
ToString(SaveFormat)Exports the content of the node into a string in the specified format.
ToString(SaveOptions)Exports the content of the node into a string using the specified save options.

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.

Document doc = new Document();
DocumentBuilder builder = new 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("Main body text.");
Footnote footnote = builder.InsertFootnote(FootnoteType.Footnote, "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.IsAuto);

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

Assert.AreEqual("\u0002 Footnote text. More text added by a DocumentBuilder.", footnote.GetText().Trim());

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

// We can set a custom reference mark which the footnote will use instead of its index number.
footnote.ReferenceMark = "RefMark";

Assert.False(footnote.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(" More main body text.");
footnote = builder.InsertFootnote(FootnoteType.Footnote, "Footnote text.");

Assert.True(footnote.IsAuto);

doc.Save(ArtifactsDir + "InlineStory.AddFootnote.docx");

See Also