安装
yum install poppler-utils
编码
function get_pages($document){
$cmd = "/usr/bin/pdfinfo"; // Linux
// $document 这是文件路径
exec("$cmd \"$document\"", $output);
$pagecount = 0;
foreach($output as $op)
{
// Extract the number
if(preg_match("/Pages:\s*(\d+)/i", $op, $matches) === 1)
{
$pagecount = intval($matches[1]);
break;
}
}
return array(true,$pagecount);
}