【问题标题】:Failed attempt to compress pdf with ghostscript - Device 'pdfwrite' requires output file尝试使用 ghostscript 压缩 pdf 失败 - 设备“pdfwrite”需要输出文件
【发布时间】:2015-09-02 14:06:11
【问题描述】:

我尝试使用以下命令压缩 pdf 文件:

gswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=test-compressed.pdf test.pdf

我在test.pdf的目录下也可以打开,但是执行命令时出现如下错误,虽然输出文件应该用-sOutputFile=test-compressed.pdf来指定:

GPL Ghostscript 9.16: Device 'pdfwrite' requires an output file but no file was specified.
**** Unable to open the initial device, quitting.

【问题讨论】:

    标签: windows compression ghostscript


    【解决方案1】:

    我自己解决了:它不适用于 PowerShell,但它适用于 cmd.exe。

    【讨论】:

      【解决方案2】:

      对我来说,PowerShell 中的以下工作:

      gswin64c -sDEVICE=pdfwrite -o test_compressed.pdf -dCompatibilityLevel='1.4' -dNOPAUSE -dQUIET -dBATCH  test.pdf
      

      【讨论】:

        【解决方案3】:

        对我来说,以下命令有效:

        & "gswin64c" "-sDEVICE=pdfwrite" "-dCompatibilityLevel=1.4" "-dNOPAUSE"
        "-dQUIET" "-dBATCH" "-sOutputFile=test-compressed.pdf" "test.pdf"
        

        【讨论】:

          【解决方案4】:

          首先,Ghostscript 的 pdfwrite 设备不会“压缩”PDF 文件。它会生成新的 PDF 文件,这些文件在视觉上应该与输入相同(无论输入是什么格式)。

          它告诉你的是你没有指定一个输出文件。所以要么你上面给出的命令行不是你实际输入的(这个错误通常是命令行输入错误的结果),要么有其他问题(例如目录不存在或者你没有权限在那里创建一个文件)

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2016-01-27
            • 2019-04-11
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多