douzinei6926
2013-09-25 09:34 阅读 21
已采纳

如何通过PHP或imagemagick检测多页PDF?

For instance, when I uploaded a file to the temp folder on server, are there any way to scan through the folder and check whether a specific file is multi page or not?

Some code like:

$files = scandir ('$tempSrc');
foreach ($files as $pdf) {
    $isMulti = //exec some command or call php function (if any?);
    echo $isMulti;
}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    doushai7225 doushai7225 2013-09-25 09:42

    You can use http://php.net/manual/en/class.imagick.php php class.

    $files = scandir ('$tempSrc');
    foreach ($files as $pdf) {
        $im = new Imagick();
        $im->pingImage($pdf);
        echo $isMulti = ($im->getNumberImages() > 1) ? true : false;
    }
    
    点赞 评论 复制链接分享

相关推荐