I get the following error and i am trying to read a few pdf files to merge them.
This is my read statement: PdfDocument inputDocument = PdfReader.Open(filename1, PdfDocumentOpenMode.ReadOnly);
and it throws this exception at : Debug.Assert(kid.Elements.GetName(Keys.Type) == "/Pages");
PdfPage.InheritValues(kid, ref values);
ArrayList list = new ArrayList();
PdfArray kids = kid.Elements["/Kids"] as PdfArray;
foreach (PdfReference xref2 in
kids)
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="PdfSharp"
StackTrace:
at PdfSharp.Pdf.PdfPages.GetKids(PdfReference iref, InheritedValues values, PdfDictionary parent) in C:\Documents and Settings\Wade\My Documents\Work\PDFsharp\PdfSharp\PdfSharp.Pdf\PdfPages.cs:line 359
at PdfSharp.Pdf.PdfPages.FlattenPageTree() in C:\Documents and Settings\Wade\My Documents\Work\PDFsharp\PdfSharp\PdfSharp.Pdf\PdfPages.cs:line 315
at PdfSharp.Pdf.Advanced.PdfCatalog.get_Pages() in C:\Documents and Settings\Wade\My Documents\Work\PDFsharp\PdfSharp\PdfSharp.Pdf.Advanced\PdfCatalog.cs:line 102
at PdfSharp.Pdf.PdfDocument.get_Pages() in C:\Documents and Settings\Wade\My Documents\Work\PDFsharp\PdfSharp\PdfSharp.Pdf\PdfDocument.cs:line 590
at PdfSharp.Pdf.PdfDocument.get_PageCount() in C:\Documents and Settings\Wade\My Documents\Work\PDFsharp\PdfSharp\PdfSharp.Pdf\PdfDocument.cs:line 480
at Pdf_Merge.Form1..ctor() in C:\Documents and Settings\Wade\My Documents\Work\Projects\Pdf Merge\Pdf Merge\Form1.cs:line 67
at Pdf_Merge.Program.Main() in C:\Documents and Settings\Wade\My Documents\Work\Projects\Pdf Merge\Pdf Merge\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Please Please help. could it be that there is a problem with my PDF file even though it opens fine in acrobat 8.
Thank you very much.
Wade