Image with no file set crash

Hi support,

If an image that has no file set, is added to a pdf document, the code will crash when trying to save it. The image must be removed by code to avoid the crash.


Hello Milan,

I've tested the scenario using the following code snippet and I am unable to see the crash. Beside this, if I specify wrong image file name, a message "System cannot find the file specified" is displayed. Whereas if I comment the code line where image file is being set, null message is displayed, but I am unable to crash. Can you please verify if the code that you are using is same as given below.


//Instantiate a Pdf object by calling its empty constructor
Pdf pdf1 = new Pdf();

//Create a section in the Pdf object
Section sec1 = pdf1.getSections().add();

//Create an image object in the section
com.aspose.pdf.elements.Image img1 = new com.aspose.pdf.elements.Image(sec1);

//Add image object into the Paragraphs collection of the section

//Set the path of image file
img1.getImageInfo().setFile("d:/pdftest/Aspos.jpg"); // commenting this line shows null over command line

//Set the path of image file
img1.getImageInfo().setTitle("JPEG image");

//Save the Pdf
FileOutputStream out = new FileOutputStream(new File("d:\\pdftest\\testimage.pdf"));;