在 Footnote 和 Endnote 中工作
Aspose.Words 也提供了一些用於處理底 Footnote 和 Endnote 的類別、方法和屬性。
插入筆記並設定編號選項
如果您想在Word文件中插入脚注或尾注,請使用InsertFootnote方法。 此方法在文件中插入註腳或尾注。
EndnoteOptions 和 FootnoteOptions 類別代表腳注和註腳的 numeration 選項。
以下範例說明如何將註腳插入到文件中並設定其編排選項:
// 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); |