PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Unhandled Exception
https://forum.pdfsharp.net/viewtopic.php?f=3&t=228
Page 1 of 1

Author:  EmbeddedChicago [ Sat Sep 22, 2007 9:41 pm ]
Post subject:  Unhandled Exception

Hello All. I am integrating your software in a project to add a watermark to a PDF document. Unfortunately I am not competent in C#. I get an exception (shown below) when I open *some* PDF Files. That is some PDFs are fine, others make the exception. Kind regard and a fine job on this project.

The code from the Watermark sample which causes the problem is here:

PdfDocument document = PdfReader.Open(filename);


The Error Output:

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at PdfSharp.Pdf.PdfPages.GetKids(PdfReference iref, InheritedValues values, P
dfDictionary parent) in C:\Projects\PDF Tools\PDFSharp-1.0.898\PDFsha
rp\PdfSharp\PdfSharp.Pdf\PdfPages.cs:line 359
at PdfSharp.Pdf.PdfPages.FlattenPageTree() in C:\Projects\PDF Tool
s\PDFSharp-1.0.898\PDFsharp\PdfSharp\PdfSharp.Pdf\PdfPages.cs:line 315
at PdfSharp.Pdf.Advanced.PdfCatalog.get_Pages() in C:\Projects\PDF
Tools\PDFSharp-1.0.898\PDFsharp\PdfSharp\PdfSharp.Pdf.Advanced\PdfCatalog.cs:li
ne 102
at PdfSharp.Pdf.PdfDocument.get_Pages() in C:\Projects\PDF Tools\P
DFSharp-1.0.898\PDFsharp\PdfSharp\PdfSharp.Pdf\PdfDocument.cs:line 590
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocument
OpenMode openmode, PdfPasswordProvider passwordProvider) in C:\Projects\PDF Tools\PDFSharp-1.0.898\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\PdfReader.cs:lin
e 388
at PdfSharp.Pdf.IO.PdfReader.Open(String path, String password, PdfDocumentOp
enMode openmode, PdfPasswordProvider provider) in C:\Projects\PDF Too
ls\PDFSharp-1.0.898\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\PdfReader.cs:line 200
at PdfSharp.Pdf.IO.PdfReader.Open(String path) in C:\Projects\PDF
Tools\PDFSharp-1.0.898\PDFsharp\PdfSharp\PdfSharp.Pdf.IO\PdfReader.cs:line 216
at Watermark.Program.Main(String[] args) in C:\Projects\PDF Tools\
PDFSharp-1.0.898\PDFsharp\Samples C#\Watermark\Program.cs:line 81

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/