Free Support Forum - aspose.com

How To See Number Of Pages Without Loading Full Document

Hi,

Is it possible to someway examine a PDF file/stream and see the number of pages in the file before processing the file? Basically we want to put a limit on the number of pages in a document that can be processed by our application and find currently by using “new com.aspose.pdf.Document( bis );” and then checking the number of pages it takes a large amount of time to process.
Thanks for any suggestions.
Gary

@mhill.labvantage

Thank you for contacting support.

I would like to share with you that, presently, whole document layout needs to be built in memory before extracting any information. However, we have logged a feature request to manipulate PDF document without loading entire document as PDFJAVA-37350 in our issue management system. I have linked this thread with the ticket and you will be notified as soon as this feature will be supported.

We are sorry for the inconvenience.

Hello,

Two and a half years on, has there been any progress on this? I have some very large PDFs and all that need is to get the page count, but it is very slow because (according to the above explanation) “whole document layout needs to be built in memory before extracting any information”.

Is there any ‘lightweight’ method to get page count?

Thanks

@ast3

We really apologize for the inconvenience and delay.

Please note that the earlier logged ticket depends upon many internal components of the API and it needs a lot of time to manipulate them in order to implement what you require. Also, we have been working over adding new features and fixes to the API in parallel.

We really request for your patience as logged ticket needs more investigation. However, we have recorded your concerns and will surely inform you as soon as we have some updates regarding ticket resolution. Please give us some more time.

We apologize for your inconvenience.

The issues you have found earlier (filed as PDFJAVA-37350) have been fixed in Aspose.PDF for Java 21.2.