Couldn't open image file

I’m using XML/XSL translation to generate the XML document that is used in the Bind and Save methods. I have in my code an Image tag to a JPEG file. For example: If file abc.jpg does not exist, the Save method throws a “Couldn’t open image file: abc.jpg” error. Is there a way to 1. check to see if the image file exists; 2. have the Image tag or Save method be smart enough to handle the missing image error and/or 3. Add an additional attribute to the Image tag to allow for a default image to be displayed it the primary image is not found.

Thank you in advance.

Dear dgertz,

Thanks for your consideration.

1) Aspose.Pdf has no function to check if a image file exists;

2) How can it handle the error since there is no image file?

3) I can add the additional attribute if you need. But how can it do if the default image does not exist?

Thanks for the reply.

1) Can you add the function to check if a image file exists?

2) Can you add an attribute to allow for the suppression of the error if the image is not found?

Basically, I want the ability to bind and save a PDF regardless if a coded image file is present or not.

3) Please add the attribute for default image if the coded image is not found.

Thanks.

Dear dgertz,

Thanks for your consideration.

Please download hot fix in thread New Release 1.5 and Its Hot Fixes.


Thanks for getting the fix out so quickly. Do you know when you’ll be able to update the PDF XML Schema located at : XML Schema of Aspose.PDF|Aspose.PDF for .NET to reflect the new changes to the ImageType schema definition?

Dear dgertz,

Thanks for your consideration.

The xsd file has been updated.


I’ve installed 1.5.10 and I’m in the process of testing. So far so good. The defaultfile works when the file is not found, but I’m getting the following error when:

1) both the file and defaultfile are not found
2) the IsImageNotFoundErrorIgnored is set to true
3) using ImageScale=“0.24”.

The error is:

Invalid image handle in GetImageWidth method:-1

I found another problem. When both the File and DefaultFile files are found, the DefaultFile is overriding File and is being displayed instead of File being displayed.

Dear dgertz,

Thanks for your consideration.

Please download hot fix again.