Is null expected from the method invocations below?

Considering the source code below, I would like to know if:

  • is it possible for the pages object to be null in any case (even with corrupted files)?
  • is it possible for the page object to be null in any case (even with corrupted files)?
  • is it possible for the collection object to be null in any case (even with corrupted files)?
// pdfDocument is instance of com.aspose.pdf.Document
PageCollection pages = pdfDocument.getPages(); 

for (com.aspose.pdf.Page page : pages) {
    com.aspose.pdf.AnnotationCollection collection = page.getAnnotations());
    // some more logic here
}

The documentation I have found doesn’t mention anything nulls being returned or not

https://reference.aspose.com/pdf/java/com.aspose.pdf/document/#getPages–
https://reference.aspose.com/pdf/java/com.aspose.pdf/page/#getAnnotations–

It might be off someone asking how the code would behave with corrupted files but we might get to know it after this code was already executed.

Thanks, in advance

@csdmalara

The exception can be caused by any reason within the supplied PDF. We are afraid that we cannot comment much on this scenario where a corrupt PDF is causing such exception. When document is loaded into memory and its pages are accessed, API reads and loads all object on the page and we need to check due to which object/resource/artifact, such exception is occurring. Can you please share some sample files for our reference so that we can open an investigation ticket and share the ID with you?

Thanks for the response.

For this particular issue I will not be able to provide a file for investigation, unfortunately.

This question was more about trying to understand better the behavior that we should expect from the API for future reference.

Best regards

@csdmalara

Sure. In case you have some particular file and face some issue with it in future, please feel free to let us know.