I want to display PDF files like image files on my WebPage on Apache2.4 on PHP7 in Windows 2008 Server, but I'm having the next error:
Fatal error: Uncaught ImagickException: PDFDelegateFailed
I already have installet ImageMagick-7.0.8-Q16 and Ghostscript 9.27 (32 bits) I replace Ghostcript 9.27 - 64 bits because the Apache Server shutdown inmediatly and restart. Here I found this note here: PHP: Uncaught ImagickException: PDFDelegateFailed .
On Command Line window:
If I run magick file.pdf file.jpg it's work.
If I run magick -verbose file.pdf file.jpg it's work and i see that it's using gswin32c.exe.
I have the same WebPage on my computer with Win10 Pro, same Imagick version, same ghostscript version, same Apache version, same PHP version and it's working fine.
$pdfInfo = new Spatie\PdfToImage\Pdf($file);
while ($page < $pdfInfo->getNumberOfPages()) {
$imagick = new Imagick();
$imagick->setResolution(100, 100);
$imagick->readImage(sprintf('%s[%s]', $file, $page));
echo sprintf('<img src="data:image/%s;base64,%s" ><br>', $type, base64_encode($imagick));
$page++;