使用脚注和尾注
Contents
[
Hide
]
Aspose.Words还提供了一些用于处理脚注和尾注的类、方法和属性。
插入尾注并设置编号选项
如果要在Word文档中插入脚注或尾注,请使用InsertFootnote方法。 此方法将脚注或尾注插入到文档中。
EndnoteOptions和FootnoteOptions类表示脚注和尾注的编号选项。
下面的代码示例演示如何将endnote插入到文档中并设置其编号选项:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
Document doc = new Document(dataDir + "TestFile.docx"); | |
DocumentBuilder builder = new DocumentBuilder(doc); | |
builder.write("Some text"); | |
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote text."); | |
EndnoteOptions option = doc.getEndnoteOptions(); | |
option.setRestartRule(FootnoteNumberingRule.RESTART_PAGE); | |
option.setPosition(EndnotePosition.END_OF_SECTION); | |
dataDir = dataDir + "TestFile_Out.doc"; | |
// Save the document to disk. | |
doc.save(dataDir); |
设置脚注布局列数
您可以使用Columns属性设置脚注布局列的数量。 如果此属性的值为0,则脚注区域将根据显示的页面上的列数设置为若干列的格式。
下面的代码示例演示如何设置脚注布局的列数:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
Document doc = new Document(dataDir + "TestFile.docx"); | |
//Specify the number of columns with which the footnotes area is formatted. | |
doc.getFootnoteOptions().setColumns(3); | |
dataDir = dataDir + "TestFile_Out.doc"; | |
// Save the document to disk. | |
doc.save(dataDir); |
设置脚注和EndNote的位置
脚注位置可以在每页的底部,也可以在每页文本的下方。 尾注位置可以在章节的末尾,也可以在文档的末尾。
下面的代码示例演示如何设置脚注和尾注的位置:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
Document doc = new Document(dataDir + "TestFile.docx"); | |
//Set footnote and endnode position. | |
doc.getFootnoteOptions().setPosition(FootnotePosition.BENEATH_TEXT); | |
doc.getEndnoteOptions().setPosition(EndnotePosition.END_OF_SECTION); | |
dataDir = dataDir + "TestFile_Out.doc"; | |
// Save the document to disk. | |
doc.save(dataDir); |