View Single Post
  #3 (permalink)  
Old 11-02-05, 02:02 PM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,167
Thanks: 3
Thanked 8 Times in 8 Posts
The simple answer is: "It is not possible"

Having said that, here is a page on the PHP.net documentation that says the following:

http://us3.php.net/pdf

Code:
How to get how many pages in a PDF? I read PDF spec. V1.6 and find this:
 
PDF set a "Page Tree Node" to define the ordering of pages in the document. The tree structure allows PDF applications, using little memory to quickly open a document containing thousands of pages.
 
If a PDF have 63 pages, the page tree node will like this...
 
2 0 obj
<< /Type /Pages
/Kidsn [ 4 0 R
			 10 0 R
			 ]
	 /Count 63		<---- YES, got it
>>
endobj
 
[P.S] a PDF may not only a pages tree node, The right answer is in "root page tree node", if /Count XX with /Parent XXX node, it not "root page tree node"
 
SO, You must find the node with /Count XX and Without /Parent terms, and you'll get total pages of PDF
 
%PDF-1.0 ~ %PDF-1.5 all works
In other words, you would simply have to look for the "/Count ", and the number of pages will be right in front of it.

For example:

Code:
/Type /Pages 
/Kids [ 2386 0 R 2388 0 R 2389 0 R 2390 0 R 2391 0 R 2392 0 R 2393 0 R ] 
/Count 67
So Once you find the "/Type /Pages" inside the text of your PDF file, the "/Count " that follows it will have the number of pages in it.
__________________

Last edited by digioz; 11-02-05 at 02:07 PM.
Reply With Quote