在centOs 7服务器上用php Imagick伪装pdf文件时出错

当我想用Imagick在php中转换pdf时,在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.
appyle 回答:在centOs 7服务器上用php Imagick伪装pdf文件时出错

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2523283.html

大家都在问