I want to embed headers - footers and images into .html file while converting from .docx to .html


I would like to embed footers , headers ,images into .html file while converting word document .docx file to .html file. I converted .docx file .html file but header and footers are not embed in that .html file . Headers and footers generated as external images. This I don’t want.

I want to embed everything into .html file whatever present inside word document after conversion.

Could you please help out with this issue. I will appreciate you.

This is very urgent requirement.


Thanks for your inquiry. Please use HtmlSaveOptions.ExportHeadersFootersMode property to specifiy how headers and footers are output to HTML, MHTML or EPUB. Default value is PerSection for HTML/MHTML and None for EPUB.

It is hard to meaningfully output headers and footers to HTML because HTML is not paginated. When this property is PerSection, Aspose.Words exports only primary headers and footers at the beginning and the end of each section. When it is FirstSectionHeaderLastSectionFooter only first primary header and the last primary footer (including linked to previous) are exported. You can disable export of headers and footers altogether by setting this property to None.

Secondly, you can embed images using HtmlSaveOptions.ExportImagesAsBase64 property. Please try running the following code for example:

Document doc = new Document(MyDir + @"TaihoConsultingAgreementTemplate_New.docx");
HtmlSaveOptions opts = new HtmlSaveOptions(SaveFormat.Html);
opts.ExportHeadersFootersMode = ExportHeadersFootersMode.PerSection;
opts.ExportImagesAsBase64 = true;
doc.Save(MyDir + @"15.10.0.html", opts);

Hope, this helps.

Best regards,