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

Free Support Forum - aspose.com

Splitting PDF in individual pages breaks the iterator

The following code throws a null reference exception after two pages:


var pageNr = 1;
var pdfDocument = new Document(GetFilePath(fileName));

foreach (Page page in pdfDocument.Pages)
{
using (var pageDocument = new Document())
{
pageDocument.Pages.Add(page);
pageDocument.Save(GetFilePath(fileName + “-page-” + pageNr));
}
pageNr++;
}

After two iterations the page object is null. Works for any PDF I tested.
If I remove the save action, the iteration works fine.

I already found an alternative in PdfFileEditor.Extract, but this code whould work anyway.

Hi,


Thanks for using our API’s.

I have tested the scenario using Aspose.Pdf for .NET 11.9.0 where I have used some of sample PDF files and I am unable to notice any issue. As per my observations, the PDF files are properly being split into individual page documents.

Can you please share your resource/input files, so that we can test the scenario in our environment. We are sorry for this inconvenience.

This issue is reproducible with Aspose pdf 17.2. Please provide this fix

Issue still reproducible with Aspose pdf 17.2 . Please provide fix ASAP.

Hi Viral,


Thanks for contacting support.

I have tested the scenario with one of my sample PDF’s and I was unable to notice any issue. The generated output(s) with throwing any exception. I have tested the whole scenario using Aspose.Pdf for .NET 17.3.0. We will really appreciate if you please provide a sample input file so that we can try to replicate the scenario in our environment. We are sorry for the inconvenience.


Best Regards,