Phpimagick library issues related to pdf processing

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.