Ошибка при создании PDF-файла с php Imagick на сервере centOs 7 - PullRequest
0 голосов
/ 03 апреля 2020

Когда я хочу преобразовать PDF в php с помощью Imagick, я получаю эту ошибку на сервере Centos 7:

 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

Мой код (успешно выполнен на локальном компьютере):

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

Я пытаюсь конвертировать с помощью терминала. но ошибка та же.

команда:

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

ошибка:

**** 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.
...