Error on convet a pdf file with php Imagick on centOs 7 server

Viewed 329

When I want convert a pdf in php with Imagick, I get this error , on centos 7 server:

 Fatal error: Uncaught ImagickException: PDFDelegateFailed `[ghostscript library 9.25] 
-sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 
-dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4
'-r72x72' '-sOutputFile=/tmp/magick-17313lqGPVXzwlu7%d' '-f/tmp/magick-1731u2enlnnoWk86' '
-f/tmp/magick-1731axoH7ck7ZoM6': 
**** Error: Cannot find a 'startxref' anywhere in the file.
Output may be incorrect. 
**** Error: An error occurred while reading an XREF table. 
**** The file has been damaged. This may have been caused 
**** by a problem while converting or transfering the file. 
**** Ghostscript will attempt to recover the data. 
**** However, the output may be incorrect. 
**** Error: Trailer dictionary not found. Output may be incorrect. 
No pages will be processed (FirstPage > LastPage). ' @ error/pdf.c/ReadPDFImage/659 in /var/www/pdf.php:8

My code (ran successfull on local):

$FILE = realpath(__DIR__ . '/test.pdf');
$im = new Imagick();
$im->pingImage($FILE);
$pageCount = $im->getNumberImages();
echo $pageCount;

I try to conver with terminal. but same error accored.

command:

convert -quality 60 -density 200 test.pdf foo.jpg

error:

**** Error: Cannot find a 'startxref' anywhere in the file.
           Output may be incorrect.
**** Error:  An error occurred while reading an XREF table.
**** The file has been damaged.  This may have been caused
**** by a problem while converting or transfering the file.
**** Ghostscript will attempt to recover the data.
**** However, the output may be incorrect.
**** Error:  Trailer dictionary not found.
            Output may be incorrect.
No pages will be processed (FirstPage > LastPage).
convert: Postscript delegate failed `test.pdf': No such file or directory @ error/pdf.c  /ReadPDFImage/678.
convert: no images defined `foo.jpg' @ error/convert.c/ConvertImageCommand/3046.
0 Answers
Related