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);
section.HeadersFooters.Add(headerPrimary);
}
headerPrimary.ChildNodes.Clear();
foreach(Node node in headerFirst.ChildNodes)
{
headerPrimary.ChildNodes.Add(node);
}
}
}