Created
May 8, 2012 09:06
-
-
Save jgdoncel/f72176ceb58d3553dd7b to your computer and use it in GitHub Desktop.
Contar páginas de un PDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getNumPagesInPDF($file) | |
{ | |
//http://www.hotscripts.com/forums/php/23533-how-now-get-number-pages-one-document-pdf.html | |
if(!file_exists($file))return null; | |
if (!$fp = @fopen($file,"r"))return null; | |
$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); | |
return (int)$max; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment