Free Support Forum -

HeaderFirst versus HeaderPrimary when saving to Html

When a simple document with a single section contains header types of HeaderFirst and HeaderPrimary, the Save(ms, SaveFormat.Html) method outputs HeaderPrimary instead of HeaderFirst. It should work like this:

if (HeaderFirst exists) then output HeaderFirst
else if (HeaderPrimary exists) then output HeaderPrimary
else if (HeaderEven exists) then output HeaderEven

When the attached document is saved as Html, the only header output should be “First Page Header”. I suppose other people might think differently, in which case a new Html save option might be necessary to control this behavior.

This is my current workaround code before executing the Save.

// If HeaderFirst exists, move it to HeaderPrimary.
foreach (Section section in doc.Sections)
HeaderFooter headerFirst = section.HeadersFooters[HeaderFooterType.HeaderFirst];
if (headerFirst != null)
HeaderFooter headerPrimary = section.HeadersFooters[HeaderFooterType.HeaderPrimary];
if (headerPrimary == null)
headerPrimary = new HeaderFooter(doc, HeaderFooterType.HeaderPrimary);
foreach (Node node in headerFirst.ChildNodes)

Hi Robert,

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

Thanks for your request. You are right, currently Aspose.Words outputs only Primary header/Footer to HTML. This is described in the documentation:

In future we are planning to output all headers/footers to HTML, like MS Word does. Your request has been linked to the appropriate issue. You will be notified as soon as this feature is available.

Best regards.