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”);
@tahir.manzoor
Remove header footer in docx file
awais.hafeez
#2
The following code should help:
Document doc = new Document("E:\\temp\\input.docx");
foreach (Section sec in doc.Sections)
{
sec.ClearHeadersFooters();
}
doc.Save("E:\\temp\\19.2.docx");
awais.hafeez
#5
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.
https://downloads.aspose.com/words/net
test.zip (12.2 KB)
I am upload .docx and converted .txt file.
i need only body data not header and footer data in .txt file
awais.hafeez
#7
The following code should help:
Document doc = new Document("E:\\test\\test.docx");
TxtSaveOptions opts = new TxtSaveOptions();
opts.setExportHeadersFootersMode(ExportHeadersFootersMode.NONE);
doc.save("E:\\test\\awjava-19.1.txt", opts);