Convert MHTML to HTML to use the DocumenBuilder


At the moment I use the DocumentBuilder to generate a Word. From outside I become some HTMLs which I insert with:


Now we want to use another technology and I have to work with a MHTML file (which is saved as Base64 and converted to MHTML). Is there an easy way to do the same? How can I convert the MHTML to HTML with Aspose, to use the same API?

Thank you!

This message was posted using Page2Forum from com.aspose.words (Aspose Words for Java) - Aspose.Words for Java

Thanks for your request. You can use the following code to convert mhtml to html:

// Open HTML
Document doc = new Document("in.mhtml");
// Save document as html"out.html");

Also, please see the following link to learn more:
Best regards,

Great! I am sorry, I have not seen it in the documentation. That is more simply than I have thought.
Thank you!

So is it right that there is no other possibility than saving the HTML temporary on disk? Because this means that the Images which were embedded in MHTML will be saved also separate on disk before I can insert the HTML with the DocumentBuilder. But this is done automatically?!

Is this right?

Best regards

Thanks for your inquiry. I think, in your case you can try storing your images as base64 in your HTML documents. Using Aspose.Words you can import and export HTML with such images:
When this ExportImagesAsBase64 property is set to true image data is exported directly on the img elements and separate files are not created.
Best regards,

Thanks! I will try it.

I hope I can still use the DocumentBuilder functionality builder.insertHTML(html).

Best regards

Thanks for your inquiry. Yes you can use InsertHtml method. Using Aspose.Words you can import and export HTML with base64 images.
Best regards,