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

Free Support Forum - aspose.com

Error when extracting page from PDF (NullReference exception)

Hi, I am trying to extract pages from a large PDF (8000~ pages) with the following code:

Random rand = new Random();
int[] pagesToExtract = new int[10];

for (int i = 0; i < pagesToExtract.Length; i++)
pagesToExtract[i] = rand.Next(1000);

PdfFileEditor editor = new PdfFileEditor();
editor.Extract(new FileStream(@“E:\bigsheetformat.pdf”, FileMode.Open), pagesToExtract, new FileStream(@“E:\extracted.pdf”, FileMode.Create));

But I get a “Object reference not set to an instance of an object.” exception.

I have uploaded a test file on which this error is replicated here:

I am using Aspose.Pdf.Kit version, along with .NET 2.0…

Stack trace:

at Aspose.Pdf.Kit.PdfFileEditor.Extract(Stream inputStream, Int32[] pageNumber, Stream outputStream)
at AsposeTest.Program.Main(String[] args) in E:\Projects\ExcelConvCleaner\AsposeTest\AsposeTest\Program.cs:line 62
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()


Thank you for considering Aspose.

I have reproduced this error and logged this issue as PDFKITNET-7059. We will try to fix it ASAP.


The issue PDFKITNET-7059 has been resolved, please download the attached Beta version of Aspose.Pdf.Kit.dll and try it before we release new version.


Hi, thanks for quick response…I was downloading the attachment but my internet got interrupted and the download got broken…now when I try to re-download, it doesn’t work…ie. I click the link and nothing happens…

I tried waiting a couple of hours, also signing in/out but still its not working…

OK it downloaded today and I tried it, pages extracted successfully…

Again thanks for the fast response