We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.PDF: Document.Pages.Add Error

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)

Hi Brian,

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,