We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to remove header and footer from word document

Hello,


Could you please guide me to remove headers and footers from a word document.
I am using aspose-words-16.8.0-jdk16 .
I have tried using below,but didn’t worked for me

for(Section section : Doc.getSections()){
section.clearHeadersFooters();
}

Thanks for your help.

Hi there,

Thanks for your inquiry. The Section.ClearHeadersFooters method clears the headers and footers of this section. The text of all headers and footers is cleared, but HeaderFooter objects themselves are not removed.

You may use HeaderFooterCollection.Clear method to removes all nodes from this collection and from the document.

Please upgrade to the latest version of Aspose.Words for Java 17.3.0. Hope this helps you. If you still face problem, please share your input document here for testing. We will investigate the issue on our side and provide you more information.