View Single Post
  #8 (permalink)  
Old 02-08-10, 02:05 PM
Baboum Baboum is offline
New Member
 
Join Date: Feb 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Since you just have to read all the file to get the Count tags, and the parent node has got one too, the following php script should work.
It looks for the largest Count tag, that is the one from the parent node. Just save it as test.php and call it with test.php?file=my_pdf_file.pdf

Code:
<?php
if (!$fp = @fopen($_REQUEST['file'],"r")) {
        echo 'failed opening file '.$_REQUEST['file'];
}
else {
        $max=0;
        while(!feof($fp)) {
                $line = fgets($fp,255);
                if (preg_match('/\/Count [0-9]+/', $line, $matches)){
                        preg_match('/[0-9]+/',$matches[0], $matches2);
                        if ($max<$matches2[0]) $max=$matches2[0];
                }
        }
        fclose($fp);
echo 'There '.($max<2?'is ':'are ').$max.' page'.($max<2?'':'s').' in '. $_REQUEST['file'].'.';
}
?>
Reply With Quote