使用脚注和尾注

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

插入尾注并设置编号选项

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

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

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

# For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET
doc = aw.Document(docs_base.my_dir + "Document.docx")
builder = aw.DocumentBuilder(doc)
builder.write("Some text")
builder.insert_footnote(aw.notes.FootnoteType.ENDNOTE, "Footnote text.")
option = doc.endnote_options
option.restart_rule = aw.notes.FootnoteNumberingRule.RESTART_PAGE
option.position = aw.notes.EndnotePosition.END_OF_SECTION
doc.save(docs_base.artifacts_dir + "WorkingWithFootnotes.set_endnote_options.docx")

设置脚注布局列数

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

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

# For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET
doc = aw.Document(docs_base.my_dir + "Document.docx")
# Specify the number of columns with which the footnotes area is formatted.
doc.footnote_options.columns = 3
doc.save(docs_base.artifacts_dir + "WorkingWithFootnotes.set_foot_note_columns.docx")

设置脚注和尾注的位置

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

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

# For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET
doc = aw.Document(docs_base.my_dir + "Document.docx")
doc.footnote_options.position = aw.notes.FootnotePosition.BENEATH_TEXT
doc.endnote_options.position = aw.notes.EndnotePosition.END_OF_SECTION
doc.save(docs_base.artifacts_dir + "WorkingWithFootnotes.set_footnote_and_end_note_position.docx")