文档半岛外围网上直营>>Aspose.Words开发者指南>>Word格式处理控件Aspose.Words for .NET教程——如何删除页脚,但保留页眉完整
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钟增强型功能,点击下载体验
文档中的每个节最多可以具有三个页眉和三个页脚(用于第一页,偶数页和奇数页)。如果要删除文档中的所有页脚,则需要遍历所有节并删除每个页脚节点。
下面的示例删除所有节中的所有页脚,但保留页眉不变。模板如下:

// 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技术交流群(642018183),我们很高兴为您提供查询和咨询。

QQ交谈
在线咨询

渝公网安备
50010702500608号

客服热线