脚注位置可以在每个页面的底部或文本下方。 脚注的默认数字格式是“1,2,3”,以下示例显示如何通过调用Section.FootnoteOptions的属性来设置脚注的位置,数字格式和重新启动规则。
首先,查看Microsoft Word下的脚注选项和原始示例文档文件:
Step 1: 创建文档的新实例并从文件加载文档
Document doc = new Document(); doc.LoadFromFile("Sample.docx",FileFormat.Docx2013);
Step 2: 从文档中获取第一部分
Section sec = doc.Sections[0];
Step 3: 设置脚注的数字格式,重新启动规则和位置
sec.FootnoteOptions.NumberFormat = FootnoteNumberFormat.UpperCaseLetter; sec.FootnoteOptions.RestartRule = FootnoteRestartRule.RestartPage; sec.FootnoteOptions.Position = FootnotePosition.PrintAtBottomOfPage;
Step 4: 将文档保存到文件
doc.SaveToFile("Footnoteoptions.docx", FileFormat.Docx2013);
设置脚注的格式之后的截图:
完整代码
Document doc = new Document(); doc.LoadFromFile("Sample.docx", FileFormat.Docx2013); Section sec = doc.Sections[0]; sec.FootnoteOptions.NumberFormat = FootnoteNumberFormat.UpperCaseLetter; sec.FootnoteOptions.RestartRule = FootnoteRestartRule.RestartPage; sec.FootnoteOptions.Position = FootnotePosition.PrintAtBottomOfPage; Clear all the formatting for the footnote and back to the default opitions //sec.FootnoteOptions.ClearFormatting(); doc.SaveToFile("Footnoteoptions.docx", FileFormat.Docx2013);