我用imagick把pdf翻译成jpg;
但由于pdf文件中存在注释,所以返回的区域为黑色,当我将图片悬停在pdf文件中时会出现注释。
图像文件:

原始pdf示例:

我的代码:
$img = new Imagick('./pige.pdf[1]');
$img->setImageBackgroundColor('white');
$img = $img->flattenImages();
$img->setImageFormat('jpg');
$img->writeImage('image.jpg');发布于 2021-04-29 07:11:34
因此,我的解决方案是使用imagick更改默认安装的gs:
这似乎是默认随ImageMagick一起安装的ghostscript版本中的错误。Ghostscript是实际执行从pdf到渲染位图的转换的程序。
我尝试了从https://www.ghostscript.com/download/gsdnld.html下载的最新版本的Ghostscript
使用命令行转换PDF:
gs-9540-linux-x86_64 -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' '-sOutputFile=/var/app/bugs/bug389/gs_output.png' '-f/var/app/bugs/bug389/pige.pdf'而且它似乎工作得很好。
我想如果你:
https://stackoverflow.com/questions/67272985
复制相似问题