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

Free Support Forum - aspose.com

Word to HTML conversion -- Image not getting dispalyed

HI,

I am using the follwoing code to convert word doc to html. The image embedded in the word doc is displayng properly if I try from my machine. When i deployed the code in our server, the images were created in Windows\Temp folder but not displayed in the converted aspx page. The ASPNET user is having read and write access to the folder. Please suggest me a solution. An immediate help will be greatly appreciated.

Stream inMS = new MemoryStream(binaryData.Length);

inMS.Write(binaryData, 0, binaryData.Length);

inMS.Position = 0;

Document inDoc = new Document(inMS);

MemoryStream outMS = new MemoryStream();

inDoc.Save(outMS, SaveFormat.Html);

Hi,

Please try specifying another folder for saving images. This may be done by means of the Document.SaveOptions.ExportImagesFolder property. Read the following API reference topics:

https://apireference.aspose.com/words/net/aspose.words.saving/htmlsaveoptions/properties/imagesfolder

https://apireference.aspose.com/words/net/aspose.words.saving/htmlsaveoptions/properties/imagesfolderalias

I have tried that already but still facing the same problem.

Please attach the source document then. BTW where does the stream data go after saving HTML to the stream? Will the images appear if you save it to a file and view the file in the browser?

I have attached the sample document. You can see a image at the end of the document (“Test signature”). The image is displayed if I browse the page from the server machine itself. But if I try to open the page from other machine then the image alone is not getting displayed. I am closing the stream at the end. Please find the code below.

Stream inMS = new MemoryStream(binaryData.Length);
inMS.Write(binaryData, 0, binaryData.Length);
inMS.Position = 0;
Document inDoc = new Document(inMS);
MemoryStream outMS = new MemoryStream();
inDoc.Save(outMS, SaveFormat.Html);
outMS.Position = 0;
StreamReader reader = new StreamReader(outMS);
ltlTest.Text = reader.ReadToEnd(); //Reading the content to a literal control
reader.Close();
outMS.Close();
inMS.Close();

Did you check SaveOptions.HtmlExportImagesFolderAlias as well? The behaviour you describe may indicate that the output HTML contains a local image URI (which is by default). Please check the HTML and if the URI is local indeed, use the aforementioned property in order to compose a remote URI.

thanks… it worked

Actually there are header and footers in that document. When the document is converted to HTML view the HTML view is not as similar as the document we see. There is a space at the start of the HTML and the contents comes next. Help me out!!

Hi

Thanks for your request. Could you please attach your documents (input DOC and output HTML) for testing? I will investigate this problem and provide you more information.

Best regards.