Question

Descrption : While converting word document to html file using aspose words, It extracts images from word document and store it in current folder and pass reference to html "src" tag , so that images can be displayed in converted html document.

Problem : When I uploaded the converted html file to Microsoft Azure cloud (i.e blob) It doesn't show the images, the reason is for images to be displayed in html file microsoft restrict to upload the embedded images to blob first and then pass the url of each images to "src" tag of html file.

How Aspose words can resolve this issues ??

I am using Asp.Net MVC 4 as a development framework.

Was it helpful?

Solution

Aspose.Words API provide the feature to export images in word file to HTML as Base64 string. This way images are embedded in the HTML file and you don't need to upload any image folder / images separately. Following is the sample code:

//Open the Word document
Document doc = new Document("C:\\data\\image.doc");

//instantiate HTML saving options
Aspose.Words.Saving.HtmlSaveOptions option = new Aspose.Words.Saving.HtmlSaveOptions();

//Export the images in doc to Base64 string
option.ExportImagesAsBase64 = true;

//Save format is HTML
option.SaveFormat = Aspose.Words.SaveFormat.Html;

//Save the resultant HTML file
doc.Save("C:\\Data\\Image2.html",option);

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top