文檔半島外圍網(wǎng)上直營>>Aspose.Words開發(fā)者指南>>Word格式處理控件Aspose.Words for .NET教程——如何刪除頁腳,但保留頁眉完整
Word格式處理控件Aspose.Words for .NET教程——如何刪除頁腳,但保留頁眉完整
Aspose.Words For .NET是一種高級Word文檔處理API,用于執(zhí)行各種文檔管理和操作任務。API支持生成,修改,轉(zhuǎn)換,呈現(xiàn)和打印文檔,而無需在跨平臺應用程序中直接使用Microsoft Word。此外,API支持所有流行的Word處理文件格式,并允許將Word文檔導出或轉(zhuǎn)換為固定布局文件格式和最常用的圖像/多媒體格式。
>>Aspose.Words for .NET已經(jīng)更新至v20.3,新增4大新功能,包括Xamarin不再需要單獨的DLL,F(xiàn)indReplaceOptions類擴展了新屬性,實現(xiàn)了“ Letterlike”符號的正確呈現(xiàn)以及支持在文本框范圍內(nèi)動態(tài)拉伸圖像,以及3鐘增強型功能,點擊下載體驗
文檔中的每個節(jié)最多可以具有三個頁眉和三個頁腳(用于第一頁,偶數(shù)頁和奇數(shù)頁)。如果要刪除文檔中的所有頁腳,則需要遍歷所有節(jié)并刪除每個頁腳節(jié)點。
下面的示例刪除所有節(jié)中的所有頁腳,但保留頁眉不變。模板如下:
// 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),我們很高興為您提供查詢和咨詢。