PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Mar 19, 2024 10:08 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Nov 28, 2019 1:09 am 
Offline

Joined: Wed Sep 28, 2016 10:44 pm
Posts: 6
Location: Kona, Hawaii
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


Attachments:
File comment: Screen shot of exception.
pdfsharp getkids null ref exception.PNG
pdfsharp getkids null ref exception.PNG [ 24.12 KiB | Viewed 9655 times ]
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 39 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group