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

Free Support Forum - aspose.com

Convert MHTML to HTML to use the DocumenBuilder

Hello!

At the moment I use the DocumentBuilder to generate a Word. From outside I become some HTMLs which I insert with:
builder.insertHtml(descriptionHTML);

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!
Regards!


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

Hi

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

doc.save("out.html");

Also, please see the following link to learn more:

http://www.aspose.com/documentation/java-components/aspose.words-for-java/about-document-conversions-in-aspose-words.html

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

Hello

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:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.saving.htmlsaveoptions.exportimagesasbase64.html

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

Hello

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

Best regards,