Image not found with InsertImage

Hello,

I am using Aspose.Words for Java 2.1 and I have recently started having problems with InsertImage. I am using it to generate a file that can be either an MS Word file or an HTML file. InsertImage had been working fine for both cases, but recently, when I generate the HTML file, I get a the empty box with red X where the images should be. When I look at the properties of the image, the Address is given as:

file:///C:/Tomcat_5.0.28/temp/Aspose.Words.ab669cef-4e75-45e0-8eee-05cbd22ce421.001.png

MS Word files still work fine. I do not believe there have been any changes to our environment. Please advise.

Hi,

There too many options in your case. Are there too many (or too big) images in your doc? Or your images converted from some format to .png?

The html export engine saves images to separate files (due the html format specification). And usually JVM (or servlet container) uses different threads to save a text (html) file and image files. Most likely the image io thread just hasn’t time to render the image. You have to check manually the address – is there any image here (other than “empty image”)? If you have original image here – this means that your view thread starts before image render thread ends. This problem can be solved by tweaking (or even just reloading) your servlet container or by application optimization (that reduces image processing time).

Also you have to check access rights for the specified dir – may be access denied for your viewer?

If you have an “empty image” image on the specified address – this is completelly another case.

Anyway, please provide additional info so that I can localize the problem: 1) the source image and 2) a small code snippet that does image configuration if any, inserts the image (the images) and saves the doc to html.

Best Regards,

Thank you for your response. Here are the some code snippets where I use insertImage:

Document report = new Document();
DocumentBuilder builder = new DocumentBuilder(report);

byte[] bullet_image = makeColoredCircle(8, Color.black);
builder.insertImage(bullet_image);

builder.insertImage(makeBanner(banner_image, highestClassification, classificationColor), RelativeHorizontalPosition.PAGE, 0, RelativeVerticalPosition.PAGE, 0, 8.572.0, 1.072.0, WrapType.THROUGH);

Something else strange I have noticed is that when I deploy my application to Tomcat locally, the images show up just fine. It’s when the application is deployed to a remote instance of Tomcat that the images do not show up. The image properties give an address in both instances, but for the remote server, the file type, size, created, and modified values are all Not Available. Please let me know what other information I can provide. Thank you for your assistance.


Hi,

So only remote Tomcat does not work? Can you open this remote image using an address from generated html? (probably, if type, size, etc. not available – not available image itself?) If you can’t open the image – it is something with Tomcat’s access rights. You have to correct the access rights to the folder where you place generated images.

Perhaps you are saving your html doc to html response stream(?). In that case you can explicitly set the folder (with public access) for images using Document.getSaveOptions().setExportImagesFolder(String).

Regards,

Thank you, but I found a work around where I didn’t have to use insertImage.