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

System.NullReferenceException Was Unhandled Error
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1086
Page 1 of 1

Author:  sswope [ Fri Mar 05, 2010 8:19 pm ]
Post subject:  System.NullReferenceException Was Unhandled Error

I am using the sample code to merge multiple PDFs into a single file. I have come across one file that produces an error in the code below.

' Iterate pages
Dim PageCount As Integer = InputDocument.PageCount
For PageIndex As Integer = 0 To PageCount - 1
' Get the page from the external document...
Dim page As PdfPage = InputDocument.Pages(PageIndex) <<===== Error
' ...and add it to the output document.
OutputDocument.AddPage(page)
Next

Here are the exception details:

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="PdfSharp"
StackTrace:
at PdfSharp.Pdf.PdfObject..ctor(PdfObject obj)
at PdfSharp.Pdf.PdfDictionary..ctor(PdfDictionary dict)
at PdfSharp.Pdf.PdfPage..ctor(PdfDictionary dict)
at PdfSharp.Pdf.PdfPages.get_Item(Int32 index)
at ConsoleApplication1.Module1.MergePDFs(List`1 SrcFilenames, String DestFilename, Boolean FullScreen) InnerException:

Any help in figuring out what is causing the error would be appreciated. I cannot provide the entire PDF file, because it is an internal document, but I may be able to provide part of it to help determine the error.

Thank you

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