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

Free Support Forum - aspose.com

How to remove header and footer of input word document

<!–[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Arial; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

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;
</font><span class="kwrd" style="color: rgb(51, 51, 51); ">foreach</span><font color="#333333"> (Section sec </font><span class="kwrd" style="color: rgb(51, 51, 51); ">in</span><font color="#333333"> doc)
{
    </font><span class="kwrd" style="color: rgb(51, 51, 51); ">if</span><font color="#333333"> (sec.HeadersFooters.Count > 0)
    {
        containsHeaderFooter = </font><span class="kwrd" style="color: rgb(51, 51, 51); ">true</span><font color="#333333">;
        </font><span class="kwrd" style="color: rgb(51, 51, 51); ">break</span><font color="#333333">;
    }
}

}


I hope this will help.