Incorrect output while converting word document to html

Hi,

I am facing issue while converting word document to html . The html file generated is incorrect . I am attaching the sample doc as well as html file.

Please help.

@saurabh.arora,

Thanks for your inquiry. Please ZIP and attach your input Word document here for testing. We will investigate the issue on our side and provide you more information.

Hi Tahir,

test2.zip (343.8 KB)

Thanks for the reply.

I am attaching my word document .

I am inserting page number through code in the footer but when i open it through word , it does not show.

Also , the page alignment is incorrect , header/footer positioning is lost.

Please help.

I am really stuck.

@saurabh.arora,

Thanks for sharing the document. Please note that Aspose.Words mimics the same behavior as MS Word does. If you convert your document to HTML using MS Word, you will get the same output.

We have converted the shared document to HTML and have not found any issue with output. Could you please share the simplified code example that helps us to reproduce your problem on our end? Please also share the screenshot of problematic section of output document.

Thanks for the reply. Can you please share your snapshot of generated html. It would be helpful for me to compare the with my output.

My code -

HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportRoundtripInformation(true);
options.setExportHeadersFootersMode(ExportHeadersFootersMode.FIRST_SECTION_HEADER_LAST_SECTION_FOOTER);
doc.save("/home/sauravarora/html.html", options);

Is there any thing else we need to do.

@saurabh.arora,

Thanks for sharing the detail. We have tested the scenario and noticed that the image position is incorrect in output HTML. Please check the attached image for detail. output.png (8.8 KB)

For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-15861. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

Regarding page number issue in the footer of document, the font size of page field is not set. Please set its font size to get the output. You can set it by using following code snippet.

for(Run run : doc.getLastSection().getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_PRIMARY).getFirstParagraph().getRuns())
{
    run.getFont().setSize(10.0);
}

Can you please share your code . Just want to check the options you set.

Thanks

@saurabh.arora,

Thanks for your inquiry. We used following code example to reproduce this issue.

Document doc = new Document(MyDir + "test2.doc");

HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportRoundtripInformation(true);
options.setExportHeadersFootersMode(ExportHeadersFootersMode.FIRST_SECTION_HEADER_LAST_SECTION_FOOTER);

for(Run run : doc.getLastSection().getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_PRIMARY).getFirstParagraph().getRuns())
{
    run.getFont().setSize(10.0);
}
doc.updateFields();
doc.save(MyDir + "output.html", options);

In your case, we suggest you please save the document to HTML_FIXED file format using following code example. Hope this helps you.

Document doc = new Document(MyDir + "test2.doc");
doc.save(MyDir + "output.html", SaveFormat.HTML_FIXED);