search/mag_sel search/close
Aspose::Words::Notes Namespace Reference

The Aspose.Words.Notes namespace provides classes to work with Microsoft Word endnotes and footnotes.

Classes

class  EndnoteOptions
 Represents the endnote numbering options for a document or section. More...
 
class  Footnote
 Represents a container for text of a footnote or endnote. More...
 
class  FootnoteOptions
 Represents the footnote numbering options for a document or section. More...
 

Enumerations

enum class  EndnotePosition
 Defines the endnote position. More...
 
enum class  FootnoteLocation
 FootnoteLocation enumeration. More...
 
enum class  FootnoteNumberingRule
 Determines when automatic footnote or endnote numbering restarts. More...
 
enum class  FootnotePosition
 Defines the footnote position. More...
 
enum class  FootnoteType
 Specifies whether this is a footnote or an endnote. More...
 

Enumeration Type Documentation

◆ EndnotePosition

Defines the endnote position.

See also
Aspose::Words::Notes::EndnoteOptions
Examples

Shows how to select a different place where the document collects and displays its endnotes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// An endnote is a way to attach a reference or a side comment to text
// that does not interfere with the main body text's flow.
// Inserting an endnote adds a small superscript reference symbol
// at the main body text where we insert the endnote.
// Each endnote also creates an entry at the end of the document, consisting of a symbol
// that matches the reference symbol in the main body text.
// The reference text that we pass to the document builder's "InsertEndnote" method.
builder->Write(u"Hello world!");
builder->InsertFootnote(FootnoteType::Endnote, u"Endnote contents.");
builder->InsertBreak(BreakType::SectionBreakNewPage);
builder->Write(u"This is the second section.");
// We can use the "Position" property to determine where the document will place all its endnotes.
// If we set the value of the "Position" property to "EndnotePosition.EndOfDocument",
// every footnote will show up in a collection at the end of the document. This is the default value.
// If we set the value of the "Position" property to "EndnotePosition.EndOfSection",
// every footnote will show up in a collection at the end of the section whose text contains the endnote's reference mark.
doc->get_EndnoteOptions()->set_Position(endnotePosition);
doc->Save(ArtifactsDir + u"InlineStory.PositionEndnote.docx");
Enumerator
EndOfSection 

Endnotes are output at the end of the section.

EndOfDocument 

Endnotes are output at the end of the document.

◆ FootnoteLocation

FootnoteLocation enumeration.

Enumerator
BottomOfPage 
BeneathText 
EndOfSection 
EndOfDocument 

◆ FootnoteNumberingRule

Determines when automatic footnote or endnote numbering restarts.

See also
Aspose::Words::Notes::FootnoteOptions
Aspose::Words::Notes::EndnoteOptions
Examples

Shows how to restart footnote/endnote numbering at certain places in the document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Footnotes and endnotes are a way to attach a reference or a side comment to text
// that does not interfere with the main body text's flow.
// Inserting a footnote/endnote adds a small superscript reference symbol
// at the main body text where we insert the footnote/endnote.
// Each footnote/endnote also creates an entry, which consists of a symbol that matches the reference
// symbol in the main body text. The reference text that we pass to the document builder's "InsertEndnote" method.
// Footnote entries, by default, show up at the bottom of each page that contains
// their reference symbols, and endnotes show up at the end of the document.
builder->Write(u"Text 1. ");
builder->InsertFootnote(FootnoteType::Footnote, u"Footnote 1.");
builder->Write(u"Text 2. ");
builder->InsertFootnote(FootnoteType::Footnote, u"Footnote 2.");
builder->InsertBreak(BreakType::PageBreak);
builder->Write(u"Text 3. ");
builder->InsertFootnote(FootnoteType::Footnote, u"Footnote 3.");
builder->Write(u"Text 4. ");
builder->InsertFootnote(FootnoteType::Footnote, u"Footnote 4.");
builder->InsertBreak(BreakType::PageBreak);
builder->Write(u"Text 1. ");
builder->InsertFootnote(FootnoteType::Endnote, u"Endnote 1.");
builder->Write(u"Text 2. ");
builder->InsertFootnote(FootnoteType::Endnote, u"Endnote 2.");
builder->InsertBreak(BreakType::SectionBreakNewPage);
builder->Write(u"Text 3. ");
builder->InsertFootnote(FootnoteType::Endnote, u"Endnote 3.");
builder->Write(u"Text 4. ");
builder->InsertFootnote(FootnoteType::Endnote, u"Endnote 4.");
// By default, the reference symbol for each footnote and endnote is its index
// among all the document's footnotes/endnotes. Each document maintains separate counts
// for footnotes and endnotes and does not restart these counts at any point.
ASSERT_EQ(doc->get_FootnoteOptions()->get_RestartRule(), FootnoteNumberingRule::Default);
// We can use the "RestartRule" property to get the document to restart
// the footnote/endnote counts at a new page or section.
doc->get_FootnoteOptions()->set_RestartRule(FootnoteNumberingRule::RestartPage);
doc->get_EndnoteOptions()->set_RestartRule(FootnoteNumberingRule::RestartSection);
doc->Save(ArtifactsDir + u"InlineStory.NumberingRule.docx");
Enumerator
Continuous 

Numbering continuous throughout the document.

RestartSection 

Numbering restarts at each section.

RestartPage 

Numbering restarts at each page. Valid for footnotes only.

Default 

Equals Continuous.

◆ FootnotePosition

Defines the footnote position.

See also
Aspose::Words::Notes::FootnoteOptions
Examples

Shows how to select a different place where the document collects and displays its footnotes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// A footnote is a way to attach a reference or a side comment to text
// that does not interfere with the main body text's flow.
// Inserting a footnote adds a small superscript reference symbol
// at the main body text where we insert the footnote.
// Each footnote also creates an entry at the bottom of the page, consisting of a symbol
// that matches the reference symbol in the main body text.
// The reference text that we pass to the document builder's "InsertFootnote" method.
builder->Write(u"Hello world!");
builder->InsertFootnote(FootnoteType::Footnote, u"Footnote contents.");
// We can use the "Position" property to determine where the document will place all its footnotes.
// If we set the value of the "Position" property to "FootnotePosition.BottomOfPage",
// every footnote will show up at the bottom of the page that contains its reference mark. This is the default value.
// If we set the value of the "Position" property to "FootnotePosition.BeneathText",
// every footnote will show up at the end of the page's text that contains its reference mark.
doc->get_FootnoteOptions()->set_Position(footnotePosition);
doc->Save(ArtifactsDir + u"InlineStory.PositionFootnote.docx");
Enumerator
BottomOfPage 

Footnotes are output at the bottom of each page.

BeneathText 

Footnotes are output beneath text on each page.

◆ FootnoteType

Specifies whether this is a footnote or an endnote.

Both footnotes and endnotes are represented by objects by the Footnote class. Use FootnoteType to distinguish between footnotes and endnotes.

See also
Aspose::Words::Notes::FootnoteType::Footnote
Examples

Shows how to reference text with a footnote and an endnote.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert some text and mark it with a footnote with the IsAuto property set to "true" by default,
// so the marker seen in the body text will be auto-numbered at "1",
// and the footnote will appear at the bottom of the page.
builder->Write(u"This text will be referenced by a footnote.");
builder->InsertFootnote(FootnoteType::Footnote, u"Footnote comment regarding referenced text.");
// Insert more text and mark it with an endnote with a custom reference mark,
// which will be used in place of the number "2" and set "IsAuto" to false.
builder->Write(u"This text will be referenced by an endnote.");
builder->InsertFootnote(FootnoteType::Endnote, u"Endnote comment regarding referenced text.", u"CustomMark");
// Footnotes always appear at the bottom of their referenced text,
// so this page break will not affect the footnote.
// On the other hand, endnotes are always at the end of the document
// so that this page break will push the endnote down to the next page.
builder->InsertBreak(BreakType::PageBreak);
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertFootnote.docx");

Shows how to insert and customize footnotes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<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.");
SharedPtr<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(u"\u0002 Footnote text. More text added by a DocumentBuilder.", footnote->GetText().Trim());
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(ArtifactsDir + u"InlineStory.AddFootnote.docx");
Enumerator
Footnote 

The object is a footnote.

Endnote 

The object is an endnote.