PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Need workaround for null ref exception in GetKids() method. https://forum.pdfsharp.net/viewtopic.php?f=2&t=4066 |
Page 1 of 1 |
Author: | bradleypeet [ Thu Nov 28, 2019 1:09 am ] | ||
Post subject: | Need workaround for null ref exception in GetKids() method. | ||
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=0 Quote: 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
|
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |