脚注と文末脚注の操作

Aspose.Wordsは、脚注と文末脚注を操作するためのクラス、メソッド、プロパティも提供します。

文末脚注の挿入と番号付けオプションの設定

Word文書に脚注または文末脚注を挿入する場合は、InsertFootnoteメソッドを使用してください。 このメソッドは、脚注または文末脚注を文書に挿入します。

EndnoteOptionsクラスとFootnoteOptionsクラスは、脚注と文末脚注の番号付けオプションを表します。

次のコード例は、文書にendnoteを挿入し、その番号付けオプションを設定する方法を示しています:

// 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の場合、脚注領域は、表示されるページの列数に基づいて列数で書式設定されます。

脚注レイアウトの列数を設定する方法を次のコード例に示します:

// 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の位置を設定します

脚注の位置は、各ページの下部または各ページのテキストの下に配置できます。 文末脚注の位置は、セクションの終わりまたは文書の終わりにすることができます。

次のコード例は、脚注と文末脚注の位置を設定する方法を示しています:

// 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);