Does anyone know how I can count the number of pages in a pdf file using php? Thanks!
See Question&Answers more detail:osDoes anyone know how I can count the number of pages in a pdf file using php? Thanks!
See Question&Answers more detail:osBased on R Ubben's answer I found the following PHP code to give good results:
function count_pages($pdfname) {
$pdftext = file_get_contents($pdfname);
$num = preg_match_all("//PageW/", $pdftext, $dummy);
return $num;
}
W
matches any non-alphanumeric character and excludes things like /Pages
, /PageMode
etc.