【问题标题】:convert png to pdf using ghostscript使用ghostscript将png转换为pdf
【发布时间】:2013-12-27 07:52:48
【问题描述】:

正如标题所说,我正在尝试将 png 转换为 pdf。 我在任何地方都找不到描述得很好的例子。

我用过这个命令

gs sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile=test.pdf test.png

但我得到的只是

Error: /syntaxerror in (binary token, type=137)
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1894   1   3   %oparray_pop   1893   1   3   %oparray_pop   1877   1   3   %oparray_pop   1771   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push
Dictionary stack:
   --dict:1161/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
GPL Ghostscript 9.07: Unrecoverable error, exit code 1

此错误消息。现在我开始考虑在ghostscript中是否可以使用这样的功能。我应该使用其他软件吗? ** 我运行的是最新的 9.07 版本

【问题讨论】:

  • 我一直使用 imagemagick:convert thisfile.png thisfile.pdf
  • 好吧,最新版本的 Ghostscript 是 9.10,但是根据我的个人经验,我在您使用的版本上遇到了一些问题,并且使用 9.06 版本解决了这些问题,这对我来说比 9.07 甚至更稳定9.10
  • 哦,好的 9.07 是自制软件中的最新可用版本。谢谢!

标签: pdf ghostscript


【解决方案1】:

是的,image magick 可以做到这一点没问题 - 这是循环遍历文件夹中所有 png 并转换为 pdf 的 cmd 行:

cd 到带有 pngs 的文件夹

mogrify -format pdf -density 300 -units PixelsPerInch *png

【讨论】:

    【解决方案2】:

    Ghostscript 可以输出多种格式(包括 png),但我不相信它能够将 png 作为输入。您也许可以使用 imagemagick 的 convert 实用程序之类的工具来实现您的目标,不过:convert test.png test.pdf

    【讨论】:

      猜你喜欢
      • 2010-11-01
      • 2011-09-08
      • 2016-03-11
      • 1970-01-01
      • 1970-01-01
      • 2017-08-08
      • 1970-01-01
      • 1970-01-01
      • 2011-05-16
      相关资源
      最近更新 更多