你最初的Ghostscript命令应该可以运行。
然而,如果你所在的目录对于运行该命令的用户不可写入,你将会收到类似以下的消息!
mbp:/$ pwd /
mbp:/$ ls -ld . drwxr-xr-x 38 root wheel 1360 Mar 10 16:20 .
mbp:/$ whoami pipitas
mbp:/$ gs -o a.pdf -sDEVICE=pdfwrite -c showpage GPL Ghostscript 9.05 (2012-02-08) Copyright (C) 2010 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. GPL Ghostscript 9.05: **** Could not open the file a.pdf . **** Unable to open the initial device, quitting.
mbp:/$ cd ~
mbp:/$ pwd /Users/pipitas
mbp:~$ ls -ld . drwxr-xr-x+ 3010 pipitas staff 102340 Mar 13 22:01 .
mbp:~$ gs -o a.pdf -sDEVICE=pdfwrite -c showpage GPL Ghostscript 9.05 (2012-02-08) Copyright (C) 2010 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details.
这个可行!
convert -units PixelsPerInch myPic.pdf -density 300 fileout.pdf
convert
来自 ImageMagick。它不能原生地处理 PDF,以保留其可能的矢量图形内容。它只能原生地处理像素图像。为了“读取”PDF,它使用 Ghostscript 作为代理,将(矢量)PDF 的页面转换为(像素)图像。一旦成为像素图像,ImageMagick 就无法返回到基于矢量的 PDF。 (这就像你无法将牛排->绞肉的过程反转。你不能从汉堡包回到鸡扒,对吧?)。这就是为什么 ImageMagick 生成的 PDF 只是嵌入到薄薄的 PDF 结构中的所有页面图像。 - Kurt Pfeifleconvert -units PixelsPerInch myPic.pdf -density 300 fileout.pdf
告诉ImageMagick:“将我的PDF文件中包含的所有内容(无论是像素图像还是矢量对象)转换为一个单一的300dpi图像,并将该图像放回到PDF页面!” - Kurt Pfeifle-density 200
。 - Andrea Lazzarotto