PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Dec 04, 2021 5:03 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 

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

System.NullReferenceException: Object reference not set to an instance of an object.
at PdfSharp.Pdf.PdfPages.GetKids(PdfReference iref, InheritedValues values, PdfDictionary parent)

using (PdfSharp.Pdf.PdfDocument source = PdfReader.Open(fileName, PdfDocumentOpenMode.ReadOnly))
    return source.Pages.Count;


Kailua Kona, HI

File comment: Screen shot of exception.
pdfsharp getkids null ref exception.PNG
pdfsharp getkids null ref exception.PNG [ 24.12 KiB | Viewed 7510 times ]
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 23 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