使用脚注和尾注

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

插入尾注并设置编号选项

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

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

下面的代码示例演示如何将endnote插入到文档中并设置其编号选项:

For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"TestFile.docx");
System::SharedPtr<DocumentBuilder> builder = System::MakeObject<DocumentBuilder>(doc);
builder->Write(u"Some text");
builder->InsertFootnote(FootnoteType::Endnote, u"Eootnote text.");
System::SharedPtr<EndnoteOptions> option = doc->get_EndnoteOptions();
option->set_RestartRule(FootnoteNumberingRule::RestartPage);
option->set_Position(EndnotePosition::EndOfSection);
System::String outputPath = outputDataDir + u"WorkingWithFootnote.SetEndnoteOptions.docx";
// Save the document to disk.
doc->Save(outputPath);

设置脚注布局列数

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

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

For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"TestFile.docx");
//Specify the number of columns with which the footnotes area is formatted.
doc->get_FootnoteOptions()->set_Columns(3);
System::String outputPath = outputDataDir + u"WorkingWithFootnote.SetFootNoteColumns.docx";
// Save the document to disk.
doc->Save(outputPath);

设置脚注和EndNote的位置

脚注位置可以在每页的底部,也可以在每页文本的下方。 尾注位置可以在章节的末尾,也可以在文档的末尾。

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

For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"TestFile.docx");
//Set footnote and endnode position.
doc->get_FootnoteOptions()->set_Position(FootnotePosition::BeneathText);
doc->get_EndnoteOptions()->set_Position(EndnotePosition::EndOfSection);
System::String outputPath = outputDataDir + u"WorkingWithFootnote.SetFootnoteAndEndNotePosition.docx";
// Save the document to disk.
doc->Save(outputPath);