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.

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.

Inheritance: FootnoteInlineStoryCompositeNodeNode

Constructors

NameDescription
Footnote(doc, footnote_type)Initializes an instance of the Footnote class.

Properties

NameDescription
actual_reference_markGets the actual text of the reference mark displayed in the document for this footnote.
countGets the number of immediate children of this node.
(Inherited from CompositeNode)
custom_node_idSpecifies custom node identifier.
(Inherited from Node)
documentGets the document to which this node belongs.
(Inherited from Node)
first_childGets the first child of the node.
(Inherited from CompositeNode)
first_paragraphGets the first paragraph in the story.
(Inherited from InlineStory)
fontProvides access to the font formatting of the anchor character of this object.
(Inherited from InlineStory)
footnote_typeReturns a value that specifies whether this is a footnote or endnote.
has_child_nodesReturns True if this node has any child nodes.
(Inherited from CompositeNode)
is_autoHolds a value that specifies whether this is a auto-numbered footnote or footnote with user defined custom reference mark.
is_compositeReturns True if this node can contain other nodes.
(Inherited from Node)
is_delete_revisionReturns true if this object was deleted in Microsoft Word while change tracking was enabled.
(Inherited from InlineStory)
is_insert_revisionReturns true if this object was inserted in Microsoft Word while change tracking was enabled.
(Inherited from InlineStory)
is_move_from_revisionReturns True if this object was moved (deleted) in Microsoft Word while change tracking was enabled.
(Inherited from InlineStory)
is_move_to_revisionReturns True if this object was moved (inserted) in Microsoft Word while change tracking was enabled.
(Inherited from InlineStory)
last_childGets the last child of the node.
(Inherited from CompositeNode)
last_paragraphGets the last paragraph in the story.
(Inherited from InlineStory)
next_siblingGets the node immediately following this node.
(Inherited from Node)
node_typeReturns NodeType.FOOTNOTE.
paragraphsGets a collection of paragraphs that are immediate children of the story.
(Inherited from InlineStory)
parent_nodeGets the immediate parent of this node.
(Inherited from Node)
parent_paragraphRetrieves the parent Paragraph of this node.
(Inherited from InlineStory)
previous_siblingGets the node immediately preceding this node.
(Inherited from Node)
rangeReturns a Range object that represents the portion of a document that is contained in this node.
(Inherited from Node)
reference_markGets/sets custom reference mark to be used for this footnote. Default value is empty string (), meaning auto-numbered footnotes are used.
story_typeReturns StoryType.FOOTNOTES or StoryType.ENDNOTES.
tablesGets a collection of tables that are immediate children of the story.
(Inherited from InlineStory)

Methods

NameDescription
accept(visitor)Accepts a visitor.
accept_end(visitor)Accepts a visitor for visiting the end of the footnote.
accept_start(visitor)Accepts a visitor for visiting the start of the footnote.
append_child(new_child)Adds the specified node to the end of the list of child nodes for this node.
(Inherited from CompositeNode)
clone(is_clone_children)Creates a duplicate of the node.
(Inherited from Node)
ensure_minimum()If the last child is not a paragraph, creates and appends one empty paragraph.
(Inherited from InlineStory)
get_ancestor(ancestor_type)Gets the first ancestor of the specified object type.
(Inherited from Node)
get_ancestor(ancestor_type)Gets the first ancestor of the specified NodeType.
(Inherited from Node)
get_child(node_type, index, is_deep)Returns an Nth child node that matches the specified type.
(Inherited from CompositeNode)
get_child_nodes(node_type, is_deep)Returns a live collection of child nodes that match the specified type.
(Inherited from CompositeNode)
get_text()Gets the text of this node and of all its children.
(Inherited from Node)
index_of(child)Returns the index of the specified child node in the child node array.
(Inherited from CompositeNode)
insert_after(new_child, ref_child)Inserts the specified node immediately after the specified reference node.
(Inherited from CompositeNode)
insert_before(new_child, ref_child)Inserts the specified node immediately before the specified reference node.
(Inherited from CompositeNode)
next_pre_order(root_node)Gets next node according to the pre-order tree traversal algorithm.
(Inherited from Node)
node_type_to_string(node_type)A utility method that converts a node type enum value into a user friendly string.
(Inherited from Node)
prepend_child(new_child)Adds the specified node to the beginning of the list of child nodes for this node.
(Inherited from CompositeNode)
previous_pre_order(root_node)Gets the previous node according to the pre-order tree traversal algorithm.
(Inherited from Node)
remove()Removes itself from the parent.
(Inherited from Node)
remove_all_children()Removes all the child nodes of the current node.
(Inherited from CompositeNode)
remove_child(old_child)Removes the specified child node.
(Inherited from CompositeNode)
remove_smart_tags()Removes all SmartTag descendant nodes of the current node.
(Inherited from CompositeNode)
select_nodes(xpath)Selects a list of nodes matching the XPath expression.
(Inherited from CompositeNode)
select_single_node(xpath)Selects the first Node that matches the XPath expression.
(Inherited from CompositeNode)
to_string(save_format)Exports the content of the node into a string in the specified format.
(Inherited from Node)
to_string(save_options)Exports the content of the node into a string using the specified save options.
(Inherited from Node)

Examples

Shows how to insert and customize footnotes.

doc = aw.Document()
builder = aw.DocumentBuilder(doc=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 = builder.insert_footnote(footnote_type=aw.notes.FootnoteType.FOOTNOTE, footnote_text='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".
self.assertTrue(footnote.is_auto)
# We can move the document builder inside the footnote to edit its reference text.
builder.move_to(footnote.first_paragraph)
builder.write(' More text added by a DocumentBuilder.')
builder.move_to_document_end()
self.assertEqual('\x02 Footnote text. More text added by a DocumentBuilder.', footnote.get_text().strip())
builder.write(' More main body text.')
footnote = builder.insert_footnote(footnote_type=aw.notes.FootnoteType.FOOTNOTE, footnote_text='Footnote text.')
# We can set a custom reference mark which the footnote will use instead of its index number.
footnote.reference_mark = 'RefMark'
self.assertFalse(footnote.is_auto)
# 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.insert_footnote(footnote_type=aw.notes.FootnoteType.FOOTNOTE, footnote_text='Footnote text.')
self.assertTrue(footnote.is_auto)
doc.save(file_name=ARTIFACTS_DIR + 'InlineStory.AddFootnote.docx')

See Also