PHP Imagick Library handling PDF issues
Fatal error:uncaught exception ' imagickexception ' with message ' Unable to open image ' Papers/1375680721.pdf ': No such fil E or directory @ error/blob.c/openblob/2622 ' in c:\xampp\htdocs\fc\editpaper.php:38 Stack trace: #0
C:\xampp\htdocs\fc\editpaper.php: 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
Report the following error
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;
}
PHP
Share to:
------Solution--------------------
Windows system running, also need to install a software ghostscript; Download address: Http://downloads.ghostscript.com/public/gs904w32.exe; I wish you success.