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

Free Support Forum - aspose.com

Images are not showing up when saved as HTML

Hi,

We are in the process of evaluating Aspose.words for Java for our application, I am trying to read a .docx file and open it as an html. I am able to read the doc, edit the contents and display it as an Html file, except that images are not getting displayed.

when I use the servletpath to save the image, the images are getting saved in the temp folder and is shown on the Html file

OutputStream dstStream = new ByteArrayOutputStream();
doc.getSaveOptions().setHtmlExportXhtmlTransitional(true);

doc.getSaveOptions().setExportImagesFolder(config.getServletContext().getRealPath("/attachments"));

doc.getSaveOptions().setHtmlExportImagesFolderAlias("/attachment");
doc.save(dstStream, SaveFormat.HTML);

Where as when i create a temp folder in the system and try to use it, the images are getting saved but never displayed on the web page.

OutputStream dstStream = new ByteArrayOutputStream();
doc.getSaveOptions().setHtmlExportXhtmlTransitional(true);

doc.getSaveOptions().setExportImagesFolder("c:\temp\attachments");
doc.getSaveOptions().setHtmlExportImagesFolderAlias("/attachment");
doc.save(dstStream, SaveFormat.HTML);

Can you let me the difference between these options and what am I doing wrong in the second option.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I think that in the second code snippet you should use the following folder alias.

doc.getSaveOptions().setHtmlExportImagesFolderAlias("file:///C:/Temp/attachments");

Also, note that image in this case will be displayed only if you open HTML on locale PC (where images are stored). I suppose you are creating web application. Therefore, I think you should save images in the temporary folder that is located in the root folder of your web application.

Best regards,