Word格式处理控件Aspose.Words for .NET教程——如何删除页脚,但保留页眉完整

Aspose.Words For .NET是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。此外,API支持所有流行的Word处理文件格式,并允许将Word文档导出或转换为固定布局文件格式和最常用的图像/多媒体格式。

>>Aspose.Words for .NET已经更新至v20.3,新增4大新功能,包括Xamarin不再需要单独的DLL,FindReplaceOptions类扩展了新属性,实现了“ Letterlike”符 的正确呈现以及支持在文本框范围内动态拉伸图像,以及3钟增强型功能体验


文档中的每个节最多可以具有三个页眉和三个页脚(用于第一页,偶数页和奇数页)。如果要删除文档中的所有页脚,则需要遍历所有节并删除每个页脚节点。

下面的示例删除所有节中的所有页脚,但保留页眉不变。模板如下:

Word格式处理控件Aspose.Words for .NET教程——如何删除页脚,但保留页眉完整

// The path to the documents directory.string dataDir = RunExamples.GetDataDir_WorkingWithDocument();Document doc = new Document(dataDir + "HeaderFooter.RemoveFooters.doc");foreach (Section section in doc){    // Up to three different footers are possible in a section (for first, even and odd pages).    // We check and delete all of them.    HeaderFooter footer;    footer = section.HeadersFooters[HeaderFooterType.FooterFirst];    if (footer != null)        footer.Remove();    // Primary footer is the footer used for odd pages.    footer = section.HeadersFooters[HeaderFooterType.FooterPrimary];    if (footer != null)        footer.Remove();    footer = section.HeadersFooters[HeaderFooterType.FooterEven];    if (footer != null)        footer.Remove();}dataDir = dataDir + "HeaderFooter.RemoveFooters_out.doc";// Save the document.doc.Save(dataDir);

还想要更多吗可以点击阅读【2019 · Aspose最新资源整合】查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(),我们很高兴为您提供查询和咨询

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年1月7日
下一篇 2020年1月7日

相关推荐

发表回复

登录后才能评论