View previous topic :: View next topic |
Author |
Message |
wadeholm
Joined: 12 Oct 2007 Posts: 3 Location: Johannesburg Southafrica
|
Posted: Fri Oct 12, 2007 6:26 am Post subject: Document null, cant read |
|
|
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 |
|
Back to top |
|
|
wadeholm
Joined: 12 Oct 2007 Posts: 3 Location: Johannesburg Southafrica
|
Posted: Fri Oct 12, 2007 6:35 am Post subject: |
|
|
Oh and i have also tried to use this code to get my pdf file: PdfDocument inputDocument = PdfReader.Open(filename1, PdfDocumentOpenMode.Import); |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Mon Oct 15, 2007 8:48 am Post subject: Re: Document null, cant read |
|
|
wadeholm wrote: | Please Please help. could it be that there is a problem with my PDF file even though it opens fine in acrobat 8. |
This could be the case - we'd need the PDF file to have a closer look.
I presume your PDF file is untypical - maybe a special case PDFsharp is not prepared for, maybe a buggy PDF file. _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
wadeholm
Joined: 12 Oct 2007 Posts: 3 Location: Johannesburg Southafrica
|
Posted: Mon Oct 15, 2007 9:52 am Post subject: |
|
|
Can i just send it to your email or how do i go about doing that
Thank you |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Thu Nov 15, 2007 4:20 pm Post subject: |
|
|
Hi!
I was able to replicate the problem.
It'll work with this change (File PdfPages.cs, around Line 358):
Code: | PdfArray kids = kid.Elements["/Kids"] as PdfArray;
//newTHHO 15.10.2007 begin
if (kids == null)
{
PdfReference xref3 = kid.Elements["/Kids"] as PdfReference;
kids = xref3.Value as PdfArray;
}
//newTHHO 15.10.2007 end
foreach (PdfReference xref2 in kids)
list.AddRange(GetKids(xref2, values, kid));
|
There are 5 new lines.
The fix will be included with the next release of PDFsharp. _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
|