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

Free Support Forum - aspose.com

Remove Header-Footer & Watermark

I have a Word document which already was edited by Aspose.jar to contain a Header & Footer and a watermark.

How can i use Aspose.jar to remove these to get back the clean and original copy of document?

Please provide the code piece if possible.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. You can use the following code to remove all headers/footers from the document.

//Open the document

Document doc = new Document("C:\\Temp\\in.doc");

//Loop through all sections and remove headers.footers

for (int i = 0; i < doc.getSections().getCount(); i++)

{

doc.getSections().get(i).getHeadersFooters().clear();

}

//Save output document

doc.save("C:\\Temp\\out.doc");

If this does not help you please attach your document for testing.

Best regards.