I've searched the forum and found other reports of this error but honestly I believe the real problem is the PDF file is corrupt. Of course it opens and displays in Adobe Acrobat just fine so our customer thinks it should "just work" everywhere. I'm looking for a workaround or hack to deal with this particular scenario. The error blows opening the file to get the page count.
Please refer to the "bad" PDF file (which contains a single scanned image) located here:
https://www.dropbox.com/s/74c3tj8z4vmb2qe/Realpage%20Invoice_1.3.pdf?dl=0Quote:
System.NullReferenceException: Object reference not set to an instance of an object.
at PdfSharp.Pdf.PdfPages.GetKids(PdfReference iref, InheritedValues values, PdfDictionary parent)
Code:
using (PdfSharp.Pdf.PdfDocument source = PdfReader.Open(fileName, PdfDocumentOpenMode.ReadOnly))
{
return source.Pages.Count;
}
Thanks,
Bradley
Kailua Kona, HI