I’ve got a app that simply open a PDF file and then attempts to copy select pages into a new document. The problem is that as soon as I add a page from the open document to the new document I can no longer continue enumerating through the pages of the open document. I get “An unhandled exception of type ‘System.NullReferenceException’ occurred “. Any ideas? I am using the latest version of the PDF library, runtime v4.0.30319 w/VS 2015. Here’s the bare bones version of my code. Also, this code worked without errors until I upgraded to the latest version of the PDF library which I need for some of the bug fixes.
Dim oPDoc As New Document(PDFFileName.Text)
Dim oNewDoc As Document = Nothing
For Each oPage In oPDoc.Pages
If HasBillingAccountHeader(oPage) Then
If oNewDoc IsNot Nothing Then oNewDoc.Save(sNewFile)
oNewDoc = New Document
sNewFile = String.Format(”{0}\Invoice for Client {1}.tmp.pdf”, PDFOutFolder.Text, sAcct)
End If
If oPage IsNot Nothing Then oNewDoc.Pages.Add(oPage)
Thanks for your inquiry. I am afraid I am not clear about your requirements from the shared sample code. I will appreciate it if you please share your sample complete code(or console application) along with source documents, so we will look into it and will guide you accordingly.
We are sorry for the inconvenience caused.
Best Regards,
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.