Làm việc với Footnote và Endnote

Aspose.Words cũng cung cấp một số lớp, phương thức và thuộc tính để làm việc với chú thích cuối trang và chú thích cuối trang.

Chèn chú thích cuối và đặt tùy chọn đánh số

Nếu bạn muốn chèn chú thích cuối trang hoặc chú thích cuối vào tài liệu Word, hãy sử dụng phương pháp InsertFootnote. Phương pháp này chèn chú thích cuối trang hoặc chú thích cuối vào tài liệu.

Các lớp EndnoteOptionsFootnoteOptions thể hiện các tùy chọn đánh số cho chú thích cuối trang và chú thích cuối trang.

Ví dụ mã sau đây cho thấy cách chèn chú thích cuối vào tài liệu và đặt các tùy chọn đánh số cho tài liệu:

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

Đặt số cột bố cục chú thích cuối trang

Bạn có thể đặt số lượng cột bố cục chú thích cuối trang bằng thuộc tính Columns. Nếu thuộc tính này có giá trị 0 thì vùng chú thích cuối trang sẽ được định dạng bằng số cột dựa trên số cột trên trang được hiển thị.

Ví dụ mã sau đây cho thấy cách đặt số cột cho bố cục chú thích cuối trang:

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

Đặt vị trí của Footnote và EndNote

Vị trí chú thích cuối trang có thể ở cuối mỗi trang hoặc bên dưới văn bản trên mỗi trang. Vị trí chú thích cuối có thể ở cuối phần hoặc cuối tài liệu.

Ví dụ mã sau đây cho thấy cách đặt vị trí của chú thích cuối trang và chú thích cuối trang:

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