About page header during converting Word files to Html files

I used Aspose.words 15.5.1 to convert two documents to html. One of the first page header that contains images and text, and the other one is empty.
But, the conversion results of empty one generated some text to page header.
I try to removed those extra text. Following is my sample code.

LayoutCollector layoutCollector = new LayoutCollector(doc);
splitter = new DocumentPageSplitter(layoutCollector);
Document pageDoc = splitter.getDocumentOfPage(page);
Document onepageDoc = splitter.getDocumentOfPage(1);
HeaderFooter headerFooter = null;
if (onepageDoc.getFirstSection().getPageSetup().getDifferentFirstPageHeaderFooter() == true && headerFooter.isHeader() == true)

But the doc that contains images and text will be affected.
So, Is there any way that the empty page header don’t generate error text?
Please help me to solve this problem and thank you for any assistance.


Thanks for your inquiry. Please try using the following code:

Document doc = new Document(getMyDir() + "Resume.docx");
HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.HTML);


doc.save(getMyDir() + "15.6.0.html", saveOptions);

I hope, this helps.

Best regards,

I tried using the above method, but it seems to affect the entire document.
After the first page, all of the header and footer content had vanished.
Are there other ways can be used to solve for the first page?

Thanks for your help :slight_smile:


Thanks for your inquiry. In general, there are three types of headers/footers e.g. FooterFirst, FooterPrimary and FooterEven. Similarly we have three types of header e.g. HeaderFirst, HeaderPrimary and HeaderEven. Here are a few details of these header/footer types:

Member Name Description
HeaderEven Header for even numbered pages.
HeaderPrimary Primary header, also used for odd numbered pages.
FooterEven Footer for even numbered pages.
FooterPrimary Primary footer, also used for odd numbered pages.
HeaderFirst Header for the first page of the section.
FooterFirst Footer for the first page of the section.

So, if you want to preserve header/footer across all pages in Word document, you can try saving to HtmlFixed format as follows:

Document doc = new Document(getMyDir() + "Resume.docx");
doc.save(getMyDir() + "15.6.0.html", SaveFormat.HTML_FIXED);

However, it is hard to meaningfully output headers and footers to normal HTML because HTML is not paginated. When ExportHeadersFootersMode 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.

Best regards,