public class FootnoteOptions
Example: Example: Example: Example: Example:
Document doc = new Document(getMyDir() + "Footnotes and endnotes.docx");
doc.getFootnoteOptions().setColumns(2);
doc.save(getArtifactsDir() + "Document.FootnoteColumns.docx");
Document doc = new Document();
DocumentBuilder builder = new 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("Hello world!");
builder.insertFootnote(FootnoteType.FOOTNOTE, "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.getFootnoteOptions().setPosition(footnotePosition);
doc.save(getArtifactsDir() + "InlineStory.PositionFootnote.docx");
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 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");
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 the document's footnotes/endnotes. Each document maintains separate counts
// for footnotes and for endnotes. By default, footnotes display their numbers using Arabic numerals,
// 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");
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 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");
Property Getters/Setters Summary | ||
---|---|---|
int | getColumns() | |
void | setColumns(intvalue) | |
Specifies the number of columns with which the footnotes area is formatted. | ||
int | getNumberStyle() | |
void | setNumberStyle(intvalue) | |
Specifies the number format for automatically numbered footnotes. The value of the property is NumberStyle integer constant. | ||
int | getPosition() | |
void | setPosition(intvalue) | |
Specifies the footnotes position. The value of the property is FootnotePosition integer constant. | ||
int | getRestartRule() | |
void | setRestartRule(intvalue) | |
Determines when automatic numbering restarts. The value of the property is FootnoteNumberingRule integer constant. | ||
int | getStartNumber() | |
void | setStartNumber(intvalue) | |
Specifies the starting number or character for the first automatically numbered footnotes. |
public int getColumns() / public void setColumns(int value)
Example:
Shows how to split the footnote section into a given number of columns.Document doc = new Document(getMyDir() + "Footnotes and endnotes.docx"); doc.getFootnoteOptions().setColumns(2); doc.save(getArtifactsDir() + "Document.FootnoteColumns.docx");
public int getNumberStyle() / public void setNumberStyle(int value)
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 the document's footnotes/endnotes. Each document maintains separate counts // for footnotes and for endnotes. By default, footnotes display their numbers using Arabic numerals, // 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");
public int getPosition() / public void setPosition(int value)
Example:
Shows how to select a different place where the document collects and displays its footnotes.Document doc = new Document(); DocumentBuilder builder = new 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("Hello world!"); builder.insertFootnote(FootnoteType.FOOTNOTE, "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.getFootnoteOptions().setPosition(footnotePosition); doc.save(getArtifactsDir() + "InlineStory.PositionFootnote.docx");
public int getRestartRule() / public void setRestartRule(int value)
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 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");
public int getStartNumber() / public void setStartNumber(int value)
This property has effect only when
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 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");