且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Ghostscript将PDF呈现为PNG时,请遵循PDF中的MediaBox/CropBox.

更新时间:2023-02-12 23:13:41

我遇到了完全相同的问题.我通过添加-dUseArtBox开关对其进行了修复.

I had exactly the same issue. I fixed it by adding -dUseArtBox switch.

示例:

 /usr/bin/gs -dUseArtBox -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=output.png input.pdf

注意:-dUseArtBox开关受支持自ghostscript版本9.07起

-dUseArtBox Sets the page size to the ArtBox rather than the MediaBox. The art box defines the extent of the page's meaningful content (including potential white space) as intended by the page's creator. The art box is likely to be the smallest box. It can be useful when one wants to crop the page as much as possible without losing the content.

-dUseArtBox Sets the page size to the ArtBox rather than the MediaBox. The art box defines the extent of the page's meaningful content (including potential white space) as intended by the page's creator. The art box is likely to be the smallest box. It can be useful when one wants to crop the page as much as possible without losing the content.