Problem when get Image

I just retrive the image from database and print in document using buider.insertImage().

If there is no image it throw error…

How can i display in image cell [“no images available”] when there is no image in database or wrong path…?

Hi,

Thanks for your inquiry. You can use File.Exists Method (String) to determine whether the specified image file exists.

Document doc = new Document(MyDir + @"in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
if (File.Exists(MyDir + "Aspose.Words.jpg"))
{
    builder.InsertImage(MyDir + "Aspose.Words.jpg");
}
else
{
    builder.Write("no images available");
}
doc.Save(MyDir + @"17.2.0.docx");

Hope, this helps.

Best regards,

Thank you so much…