I am generating thousands of PDF file, each containing up to 700 tiff (sometimes jpg) images (around an average of 500 images per PDF book). Most of them are working just fine, however I occasionally get the following error when I try to get an instance of what seems to be random tiff images.

System.NullReferenceException: Object reference not set to an instance of an object.
   at iTextSharp.text.pdf.codec.TIFFDirectory.GetFieldAsLong(Int32 tag, Int32 index)
   at iTextSharp.text.pdf.codec.TiffImage.GetTiffImageColor(TIFFDirectory dir, RandomAccessFileOrArray s)
   at iTextSharp.text.pdf.codec.TiffImage.GetTiffImage(RandomAccessFileOrArray s, Int32 page, Boolean direct)
   at iTextSharp.text.Image.GetInstance(Uri url)
   at iTextSharp.text.Image.GetInstance(String filename)
   at MDLR_PDF_Book_Maker.MDLRPDFCreator.AddImage(PagesRow page)

The line that starts all this is the following:
        Dim img As Image = Nothing
        Dim imgPath As String ' the path to the file
        ....
        img = Image.GetInstance(imgPath)
        .....

The tiff image exists and is able to be viewed in any standard tiff image viewing program (including windows xp) in all cases I have found. I am using the .Net port of iText. Has anyone else seen something similar and/or know what is causing it and/or how to fix it?

Thanks,

Matt P. Davis
Programmer Analyst
Maryland State Archives
[EMAIL PROTECTED]

Reply via email to