function getPdfPages($path){
if(!file_exists($path)) return array(false,"文件\"{$path}\"不存在!");
if(!is_readable($path)) return array(false,"文件\"{$path}\"不可读!");
// 打开文件
$fp=@fopen($path,"r");
if (!$fp) {
return array(false,"打开文件\"{$path}\"失败");
}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);
// 返回页数
return array(true,$max);
}
}用这个方法有些PDF页数获取不了 最佳答案