Corrupted .mht file after simple open-save operation

Hi. I’ve saved www.aspose.com as .mht file using IE. Then I try to run the following code:

var document = new Document(“Aspose.mht”);
document.Save(“Aspose_converted.mht”, SaveFormat.Mhtml);

This code corrupts output file to the point when it is rendered incorrectly in IE. Am I doing something wrong? How such a simple code could produce a totally unreadable output? What should I do to get a readable output?

P.S. Have a look at the files in the attachments.

Hi Artem,

Thanks for your inquiry.

But when you save this .mht to .mht format using Microsoft Word 2013, you'll observe similar behavior. So, this seems to be an expected behavior as Aspose.Words tries to mimic Microsoft Word in this case. Unfortunately, you cannot be 100% sure that converted .mht will look exactly the same as the original one was. This is because Aspose.Words is originally designed to work with Word documents formats, like DOC, DOCX, WordML, RTF etc. HTML/MHTML is not Word format and it is difficult and sometimes impossible to map between HTML and Word features. These formats are very different internally. Also, Please see the following documents to learn more about restrictions during HTML/MHTML import/export:

http://www.aspose.com/docs/display/wordsnet/Load+in+the+HTML+%28.HTML%2C+.XHTML%2C+.MHTML%29+Format
http://www.aspose.com/docs/display/wordsnet/Save+in+the+HTML+%28.HTML%2C+.XHTML%2C+.MHTML%29+Format

If we can help you with anything else, please feel free to ask.

Best regards,