在PHP中使用ImageMagick将PDF转换为JPG会产生奇数字母间距 [英] Converting a PDF to JPG with ImageMagick in PHP Gives Odd Letter Spacing
问题描述
我正在尝试通过PHP exec()
调用将PDF转换为JPG,如下所示:
I am trying to convert a PDF to a JPG with a PHP exec()
call, which looks like this:
convert page.pdf -resize 716x716 page.jpg
由于某些原因,尽管PDF在Acrobat和Mac Preview中看起来还不错,但JPG还是带有乱七八糟的文字.这是原始的PDF:
For some reason, the JPG comes out with janky text, despite the PDF looking just fine in Acrobat and Mac Preview. Here is the original PDF:
http://whit.info/dev/conversion/page.pdf
这是janktastic输出:
and here is the janktastic output:
http://whit.info/dev/conversion/page.jpg
服务器是具有PHP 5和ImageMagick 6.2.8的LAMP堆栈.
The server is a LAMP stack with PHP 5 and ImageMagick 6.2.8.
您能帮这个陷入困境的怪胎吗?
Can you help this stumped Geek?
预先感谢
W
推荐答案
ImageMagick只是调用Ghostscript将该PDF转换为图像.如果您在pdf上运行gs
,则会得到相同的间距差的输出.
ImageMagick is just going to call out to Ghostscript to convert this PDF to an image. If you run gs
on the pdf, you get the same badly-spaced output.
我怀疑Ghostscript不能很好地处理PDF的嵌入式TrueType字体.如果您可以将输出更改为嵌入Type 1字体或使用核心" PostScript字体,则将获得更好的结果.
I suspect Ghostscript isn't handling the PDF's embedded TrueType fonts very well. If you could change your output to either embed Type 1 fonts or use a "core" PostScript font, you'd get better results.
这篇关于在PHP中使用ImageMagick将PDF转换为JPG会产生奇数字母间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!