https://postimg.org/image/cvyocfg0r/I have a set of images that I'm trying to convert from images to PDF. This one in particular is giving me a hard time (attached)
When I try to code the following to convert it to PDF, I get IndexOutOfBoundsException which is fine. The problem is that I cannot catch the exception as it appears to get swallowed in the drawimage, and so I'm left with a PDF that has created 23 of the 40 or so images and I'm left not knowing there was ever an issue in the release version of the program since I only see the error during debugging. I should at least be able to catch the error and do something with it.
Code:
try
{
XGraphics xgr = XGraphics.FromPdfPage(myDoc.Pages[i]);
using (XImage img = XImage.FromFile(myArray[i]))
{
try
{
xgr.DrawImage(img, 0, 0);
}
catch (Exception ex)
{
//Log the problem and stop trying to create PDF.
}
}