Convert DOCX to HTML Header footer not showing in correct place

Hello Team,
we are converting DOCX to HTML, we are not getting the header footer in the correct place
we are using the below c# code to convert DOCX to HTML

using (MemoryStream htmlDocStream = new MemoryStream())
{
    var htmlSaveOptions = new HtmlSaveOptions();
    htmlSaveOptions.SaveFormat = SaveFormat.Html;
    htmlSaveOptions.ExportImagesAsBase64 = true;
    wordDocument.Save(htmlDocStream, htmlSaveOptions);
    htmlDocStream.Position = 0;

    File.WriteAllBytes(@"C:\Users\pthube\Downloads\output.html", htmlDocStream.ToArray());

PFA for input DOCX and Output HTML file
output.7z (27.1 KB)

@pthube This is an expected behavior. It is hard to meaningfully output headers and footers to HTML because HTML is not paginated. By default Aspose.Words exports only primary headers/footers of the document per section when saving to HTML. You can try changing ExportHeadersFootersMode to configure how headers/footers are exported to HTML.

You should note, however, that HTML documents and MS Word documents object models are quite different and it is not always possible to provide 100% fidelity after conversion one format to another.

PS: If the output HTML is for viewing purposes, i.e. it is not supposed to be edited or processed, you can consider using HtmlFixed format. In this case the output should look exactly the same as it looks in MS Word:

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

HtmlFixedSaveOptions opt = new HtmlFixedSaveOptions();
opt.PrettyFormat = true;
opt.ExportEmbeddedCss = true;
opt.ExportEmbeddedFonts = true;
opt.ExportEmbeddedImages = true;
opt.ExportEmbeddedSvg = true;

doc.Save(@"C:\Temp\out_html_fixed.html", opt);

HtmlFixed format is designed to preserve original document layout for viewing purposes. So if your goal is to display the HTML on page, then this format can be considered as an alternative. But unfortunately, it does not support roundtrip to DOCX at all.