使用脚注和尾注

Aspose.Words 还提供了一些用于处理脚注和尾注的类、方法和属性。

插入尾注并设置编号选项

如果您想在Word文档中插入脚注或尾注,请使用InsertFootnote方法。此方法将脚注或尾注插入文档中。

EndnoteOptionsFootnoteOptions 类代表脚注和尾注的编号选项。

以下代码示例演示如何将尾注插入文档并设置其编号选项:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
Document doc = new Document(dataDir + "TestFile.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Write("Some text");
builder.InsertFootnote(FootnoteType.Endnote, "Eootnote text.");
EndnoteOptions option = doc.EndnoteOptions;
option.RestartRule = FootnoteNumberingRule.RestartPage;
option.Position = EndnotePosition.EndOfSection;
dataDir = dataDir + "TestFile_Out.doc";
// Save the document to disk.
doc.Save(dataDir);

设置脚注布局列数

您可以使用 Columns 属性设置脚注布局列数。如果此属性的值为 0,则脚注区域的格式将根据显示页面上的列数设置为列数。

以下代码示例显示如何设置脚注布局的列数:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
Document doc = new Document(dataDir + "TestFile.docx");
//Specify the number of columns with which the footnotes area is formatted.
doc.FootnoteOptions.Columns = 3;
dataDir = dataDir + "TestFile_Out.doc";
// Save the document to disk.
doc.Save(dataDir);

设置脚注和尾注的位置

脚注位置可以位于每页的底部或每页文本的下方。尾注位置可以位于该节的末尾或文档的末尾。

下面的代码示例展示了如何设置脚注和尾注的位置:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
Document doc = new Document(dataDir + "TestFile.docx");
//Set footnote and endnode position.
doc.FootnoteOptions.Position = FootnotePosition.BeneathText;
doc.EndnoteOptions.Position = EndnotePosition.EndOfSection;
dataDir = dataDir + "TestFile_Out.doc";
// Save the document to disk.
doc.Save(dataDir);