com.aspose.words

Class FootnoteType

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

Utility class containing constants. Specifies whether this is a footnote or an endnote.

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

Example:

Shows how to reference text with a footnote and an endnote.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert some text and mark it with a footnote with the IsAuto attribute 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("This text will be referenced by a footnote.");
builder.insertFootnote(FootnoteType.FOOTNOTE, "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("This text will be referenced by an endnote.");
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote comment regarding referenced text.", "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.PAGE_BREAK);

doc.save(getArtifactsDir() + "DocumentBuilder.InsertFootnote.docx");

Example:

Shows how to add a footnote to a paragraph in the document and set its marker.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Add text that will be referenced by a footnote
builder.write("Main body text.");

// Add a footnote and give it text, which will appear at the bottom of the page
Footnote footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote text.");

// This attribute means the footnote in the main text will automatically be assigned a number, "1" in this instance
// The next footnote will get "2"
Assert.assertTrue(footnote.isAuto());

// We can edit the footnote's text like this
// Make sure to move the builder back into the document body afterwards
builder.moveTo(footnote.getFirstParagraph());
builder.write(" More text added by a DocumentBuilder.");
builder.moveToDocumentEnd();

Assert.assertEquals(footnote.getParagraphs().get(0).toString(SaveFormat.TEXT).trim(), "Footnote text. More text added by a DocumentBuilder.");

builder.write(" More main body text.");
footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote text.");

// Substitute the reference number for our own custom mark by setting this variable, "IsAuto" will also be set to false
footnote.setReferenceMark("RefMark");
Assert.assertFalse(footnote.isAuto());

// This bookmark will get a number "3" even though there was no "2"
builder.write(" More main body text.");
footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote text.");
Assert.assertTrue(footnote.isAuto());

doc.save(getArtifactsDir() + "InlineStory.AddFootnote.docx");
See Also:
FOOTNOTE

Field Summary
static final intFOOTNOTE = 0
The object is a footnote.
static final intENDNOTE = 1
The object is an endnote.
 

    • Field Detail

      • FOOTNOTE = 0

        public static final int FOOTNOTE
        The object is a footnote.
      • ENDNOTE = 1

        public static final int ENDNOTE
        The object is an endnote.