function pdf2png($PDF,$toPath,$page){ if(!extension_loaded('imagick')){ echo "imagick"; return false; } if(!file_exists($PDF)){ echo "noexists"; return false; } $IM = new imagick(); $IM->setResolution(1000,2000); $IM->setCompressionQuality(100); $IM->readImage($PDF."[".$page."]"); foreach ($IM as $Key => $Var){ $Var->setImageFormat('png'); $Filename = $toPath.time().'_'.$Key.'.png'; if($Var->writeImage($Filename) == true){ $Return[] = $Filename; } } return $Return; } |
报如下错误:
Fatal error: Uncaught exception 'ImagickException' with message 'unable to open image `papers/1375680721.pdf': No such file or directory @ error/blob.c/OpenBlob/2622' in C:\xampp\htdocs\fc\editpaper.php:38 Stack trace: #0
C:\xampp\htdocs\fc\editpaper.php(38): Imagick->readimage('papers/13756807...') #1 C:\xampp\htdocs\fc\editpaper.php(108): pdf2png('papers/13756807...', 'papers/', 0) #2 C:\xampp\htdocs\fc\editpaper.php(211): anli->insert('') #3 {main} thrown in C:\xampp\htdocs\fc\editpaper.php on line 38
------解决方案--------------------
Windows系统下运行,还需要装一个安装软件ghostscript;下载地址:http://downloads.ghostscript.com/public/gs904w32.exe ; 祝你成功。
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!