View Single Post
  #13 (permalink)  
Old 02-22-10, 02:25 AM
Baboum Baboum is offline
New Member
 
Join Date: Feb 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Solution ?

I tried adding this to count the number of 'Type/Page' appearing in the document, and that worked until I tried with you document :
PHP Code:

    if ($max===0){

            if (
$fp = @fopen($file,"r")) {   
            while(!
feof($fp)) {
                
$line fgets($fp,255);
                if (
preg_match('/\/Type\/Page/'$line)) $max++;
            }    
            
fclose($fp);
        }
    }
    return 
$max
That returned 28 pages instead of 16. So I just had a look at Count The Number of Pages in a PDF - PHP - Snipplr (thanks wirehopper ) and the first message gave me the solution (using Ubuntu Karmic) :
PHP Code:

exec('pdfinfo '.$file.' | awk \'/Pages/ {print $2}\''); 

It worked perfectly on your document. I will keep this one. Simple, fast and efficient.
Reply With Quote