Free Support Forum -

Iterating through the PDF Document PagesCollection throws a null reference exception

I have a problem where iterating through the pdf files' pages collection throws a null reference error. Is there a way where i can get the pages of a pdf document and add them to another pdf document? Below is the code that is throwing the null reference exception.

string pdfFilePath = @"C:\Data\Folio Automation\Watch\PDFCombine\HFD_AME003_95212_400024Fourie 1158481 (2012-11-29 08.00.31).pdf";

Document pdfDocumentSource = new Document(pdfFilePath);
foreach (Page page in pdfDocumentSource.Pages)
// document.Pages.Add(page);

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for using our product.

I tested your template files with sample code and I am unable to reproduce the issue with the latest version of Aspose.Pdf for .NET v7.5. If you are using an older version, please download and try the latest version and let us know if you still face any issue.

Regarding concatenation of two documents, please see the following documentation link for your reference:

Concatenate PDF Files

Please feel free to contact support in case you need any further assistance.

Sorry for the inconvenience,


Thanks version 7.5 sort of fixed the issue. I was using version 7.3 and we have a licence for version 7.3 and now i am having an issue where 7.5 is evaluation only. How can we upgrade our licence for version7.5


Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the feedback and confirmation regarding the resolution of your issue.

To upgrade your license subscription, you may post your request with details to our Aspose.Purchase forum and our Sales Team will get back to you soon.

Sorry for the inconvenience,