Free Support Forum -

Remove header footer in docx file


remove header and footer in docx file. Then write this code.
Because I don’t want header footer data and also page number.
Document doc = new Document(MyDir + “in.docx”);
doc.Save(MyDir + “output.txt”);



The following code should help:

Document doc = new Document("E:\\temp\\input.docx");

foreach (Section sec in doc.Sections)



But i also want to remove the page number . how to remove it.


this code i am not able to build in maven.what is the dependency for it



Please ZIP and attach your sample Word document here for testing. We will then investigate the issue on our end and provide you more information.

You need to add Aspose.Words for .NET DLL reference in your project to be able to run this code.

#6 (12.2 KB)
I am upload .docx and converted .txt file.
i need only body data not header and footer data in .txt file



The following code should help:

Document doc = new Document("E:\\test\\test.docx");

TxtSaveOptions opts = new TxtSaveOptions();
opts.setExportHeadersFootersMode(ExportHeadersFootersMode.NONE);"E:\\test\\awjava-19.1.txt", opts);