Images dissapear when Save HTML content to Word File

Hi all

I have troubles to visualize some images when I export html content to doc.Attahced you will find the html content and the output for 2 tests I did. In both images appear like red square. No error messages or any exception. Java version is jdk 1.4 and I tested on Websphere server version 6.0.2.15. Also I have installed Office 2007 but I save my document with doc extension not docx.

Here the code I run:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertHtml(htmlContent);
fileName= documentPath + System.currentTimeMillis() + ".doc";
builder.getDocument().save(fileName,SaveFormat.DOC);

Hi

Thanks for your inquiry. The problem occurs because Aspose.Words cannot access these pictures. Most likely, you should have authorized access to the site where these pictures are located.

<IMG src="https://wachoviasec1/manager/1ppamanager/mgrstatic/attach/embimages/HT27245New Image for Test.GIF" border=0>

Best regards.

I did a second test and I changed the HTML to something like

<IMG style="WIDTH: 443px; HEIGHT: 236px" height=293 src="file:///C://HT27245New%20Image%20for%20Test.GIF" width=829 border=0>

Export works ok , the URL https://wachoviasec1/manager/1ppamanager/mgrstatic/attach/embimages/HT27245New%20Image%20for%20Test.GIF is totally visible from my pc, I tried with several address that I have full access and the same happens, images are not showed.
Is it a kind of issue if images are in a different network address?

Hi

Thank you for additional information. I think the problem occurs because you should specify network credentials to access this web site. Currently, there is no way to set network credentials of Document. I linked your request to the appropriate issue.

Maybe, as a workaround, you can parse your HTML, create locale copies of each image in the HTML document and use local path instead URI.

Best regards.

Alexey

There is no credential access required to access https site, and even I tested on single http URI and the same issue happens, So Im really sure that it is not the root cause of issue. My client is not able to write into any local drive so we have to find other way to do. Please tell me your comments as soon as you can,

Hi

Thank you for additional information. Actually, this works fine on my side. I used the following code for testing:

// Create docuemnt and DocumentBuilder
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

//Insert HTML
builder.insertHtml("<IMG src='http://www.software112.com/images/Development/Oldies/Screenshots/3634-aspose-word.gif' align=left border=0>");

// Save output document
doc.save("C:\\Temp\\out.doc")

Images are inserted into the document without any issues.

Best regards.

Hi buddy,

Could you please test again but renaming your image file to 3634 aspose word.gif ?

Seems that the problem is related to how the tool is taking the name of the pic when it includes spaces in the name.

Regards,

Hi

Thank you for additional information. Actually, urls cannot contain whitespaces. Whitespaces in urls should be escaped with %20. See the following example:

// Create docuemnt and DocumentBuilder
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

//Insert HTML
builder.insertHtml("<IMG src='http://www.software112.com/images/Development/Oldies/Screenshots/3634%20aspose%20word.gif' align=left border=0>");

// Save output document
doc.save("C:\\Temp\\out.doc")

Best regards.

The issues you have found earlier (filed as WORDSNET-927) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(38)