com.aspose.words

Class EndnoteOptions

  • java.lang.Object
    • com.aspose.words.EndnoteOptions
public class EndnoteOptions 
extends java.lang.Object

Represents the endnote numbering options for a document or section.

Example:

Shows how to select a different place where the document collects and displays its endnotes.
Document doc = new Document();
DocumentBuilder builder = new 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("Hello world!");
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote contents.");
builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
builder.write("This is the second section.");

// We can use the "Position" property to determine where the document will place all of 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.getEndnoteOptions().setPosition(endnotePosition);

doc.save(getArtifactsDir() + "InlineStory.PositionEndnote.docx");

Example:

Shows how to set a number at which the document begins the footnote/endnote count.
Document doc = new Document();
DocumentBuilder builder = new 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("Text 1. ");
builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 1.");
builder.write("Text 2. ");
builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 2.");
builder.write("Text 3. ");
builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 3.");

builder.insertParagraph();

builder.write("Text 1. ");
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 1.");
builder.write("Text 2. ");
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 2.");
builder.write("Text 3. ");
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 3.");

// By default, the reference symbol for each footnote and endnote is its index
// among all of the document's footnotes/endnotes. Each document maintains separate counts
// for footnotes and for endnotes, which both begin at 1.
Assert.assertEquals(1, doc.getFootnoteOptions().getStartNumber());
Assert.assertEquals(1, doc.getEndnoteOptions().getStartNumber());

// We can use the "StartNumber" property to get the document to
// begin a footnote or endnote count at a different number.
doc.getEndnoteOptions().setNumberStyle(NumberStyle.ARABIC);
doc.getEndnoteOptions().setStartNumber(50);

doc.save(getArtifactsDir() + "InlineStory.StartNumber.docx");

Example:

Shows how to change the number style of footnote/endnote reference marks.
Document doc = new Document();
DocumentBuilder builder = new 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("Text 1. ");
builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 1.");
builder.write("Text 2. ");
builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 2.");
builder.write("Text 3. ");
builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 3.", "Custom footnote reference mark");

builder.insertParagraph();

builder.write("Text 1. ");
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 1.");
builder.write("Text 2. ");
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 2.");
builder.write("Text 3. ");
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 3.", "Custom endnote reference mark");

// By default, the reference symbol for each footnote and endnote is its index
// among all of the document's footnotes/endnotes. Each document maintains separate counts
// for footnotes and for endnotes. By default, footnotes display their numbers in arabic,
// and endnotes display their numbers in lowercase Roman numerals.
Assert.assertEquals(NumberStyle.ARABIC, doc.getFootnoteOptions().getNumberStyle());
Assert.assertEquals(NumberStyle.LOWERCASE_ROMAN, doc.getEndnoteOptions().getNumberStyle());

// We can use the "NumberStyle" property to apply custom numbering styles to footnotes and endnotes.
// This will not affect footnotes/endnotes with custom reference marks.
doc.getFootnoteOptions().setNumberStyle(NumberStyle.UPPERCASE_ROMAN);
doc.getEndnoteOptions().setNumberStyle(NumberStyle.UPPERCASE_LETTER);

doc.save(getArtifactsDir() + "InlineStory.RefMarkNumberStyle.docx");

Example:

Shows how to restart footnote/endnote numbering at certain places in the document.
Document doc = new Document();
DocumentBuilder builder = new 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("Text 1. ");
builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 1.");
builder.write("Text 2. ");
builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 2.");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.write("Text 3. ");
builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 3.");
builder.write("Text 4. ");
builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 4.");

builder.insertBreak(BreakType.PAGE_BREAK);

builder.write("Text 1. ");
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 1.");
builder.write("Text 2. ");
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 2.");
builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
builder.write("Text 3. ");
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 3.");
builder.write("Text 4. ");
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 4.");

// By default, the reference symbol for each footnote and endnote is its index
// among all of the document's footnotes/endnotes. Each document maintains separate counts
// for footnotes and endnotes and does not restart these counts at any point.
Assert.assertEquals(doc.getFootnoteOptions().getRestartRule(), FootnoteNumberingRule.DEFAULT);
Assert.assertEquals(FootnoteNumberingRule.DEFAULT, FootnoteNumberingRule.CONTINUOUS);

// We can use the "RestartRule" property to get the document to restart
// the footnote/endnote counts at a new page or section.
doc.getFootnoteOptions().setRestartRule(FootnoteNumberingRule.RESTART_PAGE);
doc.getEndnoteOptions().setRestartRule(FootnoteNumberingRule.RESTART_SECTION);

doc.save(getArtifactsDir() + "InlineStory.NumberingRule.docx");
See Also:
Document.EndnoteOptions, PageSetup.EndnoteOptions

Property Getters/Setters Summary
intgetNumberStyle()
void
setNumberStyle(intvalue)
           Specifies the number format for automatically numbered endnotes. The value of the property is NumberStyle integer constant.
intgetPosition()
void
setPosition(intvalue)
           Specifies the endnotes position. The value of the property is EndnotePosition integer constant.
intgetRestartRule()
void
setRestartRule(intvalue)
           Determines when automatic numbering restarts. The value of the property is FootnoteNumberingRule integer constant.
intgetStartNumber()
void
setStartNumber(intvalue)
           Specifies the starting number or character for the first automatically numbered endnotes.
 

    • Property Getters/Setters Detail

      • getNumberStyle/setNumberStyle

        public int getNumberStyle() / public void setNumberStyle(int value)
        
        Specifies the number format for automatically numbered endnotes. The value of the property is NumberStyle integer constant.

        Not all number styles are applicable for this property. For the list of applicable number styles see the Insert Footnote or Endnote dialog box in Microsoft Word. If you select a number style that is not applicable, Microsoft Word will revert to a default value.

        Example:

        Shows how to change the number style of footnote/endnote reference marks.
        Document doc = new Document();
        DocumentBuilder builder = new 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("Text 1. ");
        builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 1.");
        builder.write("Text 2. ");
        builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 2.");
        builder.write("Text 3. ");
        builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 3.", "Custom footnote reference mark");
        
        builder.insertParagraph();
        
        builder.write("Text 1. ");
        builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 1.");
        builder.write("Text 2. ");
        builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 2.");
        builder.write("Text 3. ");
        builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 3.", "Custom endnote reference mark");
        
        // By default, the reference symbol for each footnote and endnote is its index
        // among all of the document's footnotes/endnotes. Each document maintains separate counts
        // for footnotes and for endnotes. By default, footnotes display their numbers in arabic,
        // and endnotes display their numbers in lowercase Roman numerals.
        Assert.assertEquals(NumberStyle.ARABIC, doc.getFootnoteOptions().getNumberStyle());
        Assert.assertEquals(NumberStyle.LOWERCASE_ROMAN, doc.getEndnoteOptions().getNumberStyle());
        
        // We can use the "NumberStyle" property to apply custom numbering styles to footnotes and endnotes.
        // This will not affect footnotes/endnotes with custom reference marks.
        doc.getFootnoteOptions().setNumberStyle(NumberStyle.UPPERCASE_ROMAN);
        doc.getEndnoteOptions().setNumberStyle(NumberStyle.UPPERCASE_LETTER);
        
        doc.save(getArtifactsDir() + "InlineStory.RefMarkNumberStyle.docx");
      • getPosition/setPosition

        public int getPosition() / public void setPosition(int value)
        
        Specifies the endnotes position. The value of the property is EndnotePosition integer constant.

        Example:

        Shows how to select a different place where the document collects and displays its endnotes.
        Document doc = new Document();
        DocumentBuilder builder = new 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("Hello world!");
        builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote contents.");
        builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
        builder.write("This is the second section.");
        
        // We can use the "Position" property to determine where the document will place all of 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.getEndnoteOptions().setPosition(endnotePosition);
        
        doc.save(getArtifactsDir() + "InlineStory.PositionEndnote.docx");
      • getRestartRule/setRestartRule

        public int getRestartRule() / public void setRestartRule(int value)
        
        Determines when automatic numbering restarts. The value of the property is FootnoteNumberingRule integer constant.

        Not all values are applicable to endnotes. To ascertain which values are applicable see FootnoteNumberingRule.

        Example:

        Shows how to restart footnote/endnote numbering at certain places in the document.
        Document doc = new Document();
        DocumentBuilder builder = new 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("Text 1. ");
        builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 1.");
        builder.write("Text 2. ");
        builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 2.");
        builder.insertBreak(BreakType.PAGE_BREAK);
        builder.write("Text 3. ");
        builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 3.");
        builder.write("Text 4. ");
        builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 4.");
        
        builder.insertBreak(BreakType.PAGE_BREAK);
        
        builder.write("Text 1. ");
        builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 1.");
        builder.write("Text 2. ");
        builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 2.");
        builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
        builder.write("Text 3. ");
        builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 3.");
        builder.write("Text 4. ");
        builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 4.");
        
        // By default, the reference symbol for each footnote and endnote is its index
        // among all of the document's footnotes/endnotes. Each document maintains separate counts
        // for footnotes and endnotes and does not restart these counts at any point.
        Assert.assertEquals(doc.getFootnoteOptions().getRestartRule(), FootnoteNumberingRule.DEFAULT);
        Assert.assertEquals(FootnoteNumberingRule.DEFAULT, FootnoteNumberingRule.CONTINUOUS);
        
        // We can use the "RestartRule" property to get the document to restart
        // the footnote/endnote counts at a new page or section.
        doc.getFootnoteOptions().setRestartRule(FootnoteNumberingRule.RESTART_PAGE);
        doc.getEndnoteOptions().setRestartRule(FootnoteNumberingRule.RESTART_SECTION);
        
        doc.save(getArtifactsDir() + "InlineStory.NumberingRule.docx");
      • getStartNumber/setStartNumber

        public int getStartNumber() / public void setStartNumber(int value)
        
        Specifies the starting number or character for the first automatically numbered endnotes.

        This property has effect only when RestartRule is set to FootnoteNumberingRule.CONTINUOUS.

        Example:

        Shows how to set a number at which the document begins the footnote/endnote count.
        Document doc = new Document();
        DocumentBuilder builder = new 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("Text 1. ");
        builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 1.");
        builder.write("Text 2. ");
        builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 2.");
        builder.write("Text 3. ");
        builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote 3.");
        
        builder.insertParagraph();
        
        builder.write("Text 1. ");
        builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 1.");
        builder.write("Text 2. ");
        builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 2.");
        builder.write("Text 3. ");
        builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote 3.");
        
        // By default, the reference symbol for each footnote and endnote is its index
        // among all of the document's footnotes/endnotes. Each document maintains separate counts
        // for footnotes and for endnotes, which both begin at 1.
        Assert.assertEquals(1, doc.getFootnoteOptions().getStartNumber());
        Assert.assertEquals(1, doc.getEndnoteOptions().getStartNumber());
        
        // We can use the "StartNumber" property to get the document to
        // begin a footnote or endnote count at a different number.
        doc.getEndnoteOptions().setNumberStyle(NumberStyle.ARABIC);
        doc.getEndnoteOptions().setStartNumber(50);
        
        doc.save(getArtifactsDir() + "InlineStory.StartNumber.docx");