How to remove header and footer of input word document

Hi,
We are using Aspose.word 10.5.0.0. DLL to generating HTML of input word document.
In our application, there is requirement in which we have to upload a word document, convert this word to html.
this input word document may have any type of data like image ,table some times we found that this input word document has also enable the header and footer in some section and as per our requiremnt we don’t have to allow header and footer of input word document.
so in aspose is there any way in which we can found that input document has header and footer option is on or any solution in which we can off or remove this header and footer from the input word document.
So please let us know if there is any way to get the information for header and footer and remove it from the section of word document.
Please let us know if any solution is possible. It is very helpful for us.
Thanks
Samanvay.

Hi
Samanvay,

Thanks for your inquiry. Sure, you can try specifying how headers and footers are output to HTML, MHTML or EPUB formats by using the following code snippet:

Document doc = new Document(MyDir + "HeaderFooter.RemoveFooters.doc");

HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.Html);
// Disables exporting headers and footers.
saveOptions.ExportHeadersFootersMode = ExportHeadersFootersMode.None;

doc.Save(MyDir + "HeaderFooter.DisableHeadersFooters Out.html", saveOptions);

Moreover, the default value of HtmlSaveOptions.ExportHeadersFootersMode property is PerSection for HTML/MHTML and None for EPUB.

I hope, this will help.

Best Regards,

thanks for your quick response

But it will avoid the header and footer in html. i need to check that input document have header and footer or not.

so is there any way in which we can check that the header and footer option in input document is on or off or enable and disable.

Please help us on this

Hi Samanvay,

Thanks for your inquiry. Please follow up the code snippet to check header and footer:

private static void ProcessDocument(Document doc)
{
    bool containsHeaderFooter = false;
    foreach (Section sec in doc)
    {
        if (sec.HeadersFooters.Count > 0)
        {
            containsHeaderFooter = true;
            break;
        }
    }
}

I hope this will help.