We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Header image is lost after DOC to HTML conversion using Java

Header images are not present in Aspose Output of Word to html.
As you can see in the word document, the header has 2 images. But they don’t show in Aspose output.

Document : 2450216-1-1.doc.zip (1.5 MB)
Aspose Output: AsposeResult.txt.zip (35.8 KB)

Code :
Document doc = new Document(“E:\Temp\1-s2.0-Simple.doc\1-s2.0-Simple.doc”);
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportImagesAsBase64(true);
options.setExportFontsAsBase64(true);
options.setExportRoundtripInformation(false);
options.setExportListLabels(ExportListLabels.BY_HTML_TAGS)
ByteArrayOutputStream out = new ByteArrayOutputStream();
doc.save(out, options);
String result = new String(out.toByteArray(), StandardCharsets.UTF_8);
System.out.println(result);

Please assist

@NehaSachdeva

Please note that Aspose.Words mimics the behavior of MS Word. If you convert your document to HTML, you will get the same output.

Yeah so that was my question . I think I wasn’t clear. So my question is why the Aspose result doesn’t have those header images ? They are in the word doc but not in the Aspose result .

@NehaSachdeva

Please note that HtmlSaveOptions.ExportHeadersFootersMode property is used to specify how headers and footers are output to HTML, MHTML or EPUB. Default value is PerSection for HTML/MHTML.

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.

Please use the following code example to get the desired output.

Document doc = new Document(MyDir+ "2450216-1-1.doc");
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportImagesAsBase64(true);
options.setExportFontsAsBase64(true);
options.setExportRoundtripInformation(false);
options.setExportListLabels(ExportListLabels.BY_HTML_TAGS);
options.setExportHeadersFootersMode(ExportHeadersFootersMode.FIRST_PAGE_HEADER_FOOTER_PER_SECTION);
doc.save(MyDir + "out.html", options);