Search code examples
phppdfghostscriptimagickphp-7.4

Fatal error: Uncaught ImagickException: PDFDelegateFailed `The system cannot find the file specified


I want to convert pdf file to jpg. I installed imagick correctly and I installed ghoscript 9.53.3 64x but I got this error. I put the ghoscript / bin and lib path in the enviroment variable.

Fatal error: Uncaught ImagickException: PDFDelegateFailed `The system cannot find the file specified. ' @ error/pdf.c/ReadPDFImage/794 in C:\xampp7.4\htdocs\kOnline\vendor\spatie\pdf-to-image\src\Pdf.php:40 Stack trace: #0 C:\xampp7.4\htdocs\kOnline\vendor\spatie\pdf-to-image\src\Pdf.php(40): Imagick->pingimage('C:/xampp7.4/htd...') #1 C:\xampp7.4\htdocs\kOnline\pdfToImaage.php(8): Spatie\PdfToImage\Pdf->__construct('C:/xampp7.4/htd...') #2 {main} thrown in C:\xampp7.4\htdocs\kOnline\vendor\spatie\pdf-to-image\src\Pdf.php on line 40

my code:

$pdf = new Spatie\PdfToImage\Pdf($pathToPdf);


foreach (range(1, $pdf->getNumberOfPages()) as $pageNumber) {

    $pdf->setPage($pageNumber);

    $pdf->saveImage("Image_name".$pageNumber.".png");
}

PHP Version 7.4.11

Apache Version Apache/2.4.46 (Win64) OpenSSL/1.1.1g PHP/7.4.11

ghoscript 9.53.3 64x

imagick module version 3.4.4

OS windows 10 64x

enter image description here

enter image description here


Solution

  • I uninstalled ghoscript 9.53.3 and installed ghoscript 9.26. I restarted the system after installation. That's all and my problem was solved.