Fatal & nbsp; error: & nbsp; Uncaught & nbsp; exception & nbsp; 'imagickexception' & nbsp; with & nbsp; message & nbsp; 'unable & nbsp; to php imagick library to handle pdf problems
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): 1272png ('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
The following error is reported:
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;
}
Share with PHP:
------ Solution --------------------
Run in Windows, you also need to install a software ghostscript;: http://downloads.ghostscript.com/public/gs904w32.exe; wish you success.