Heim >Backend-Entwicklung >PHP-Tutorial >php imagick库处理pdf有关问题
php imagick库处理pdf问题
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
报如下错误
function pdf2png($PDF,$toPath,$page){ <br /> if(!extension_loaded('imagick')){<br /> echo "imagick";<br /> return false; <br /> } <br /> if(!file_exists($PDF)){<br /> echo "noexists";<br /> return false; <br /> }<br /> $IM = new imagick(); <br /> $IM->setResolution(1000,2000); <br /> $IM->setCompressionQuality(100); <br /> $IM->readImage($PDF."[".$page."]");<br /> foreach ($IM as $Key => $Var){<br /> $Var->setImageFormat('png'); <br /> $Filename = $toPath.time().'_'.$Key.'.png'; <br /> if($Var->writeImage($Filename) == true){ <br /> $Return[] = $Filename; <br /> }<br /> }<br /> return $Return;<br />}