【问题标题】:ghostscript stackunderflow in --dup-- error--dup--错误中的ghostscript stackunderflow
【发布时间】:2021-09-15 18:35:11
【问题描述】:

我正在尝试使用 ghost 脚本将 jpg 转换为 pdf。我使用的命令是

 C:\Users\kbged\Desktop\XAMPP\php\bin\gs\gs9.54.0\bin\gswin64c  -sDEVICE=pdfwrite -sOutputFile=C:\Users\kbged\Pictures\php48D4.pdf C:\Users\kbged\Desktop\XAMPP\php\bin\gs\gs9.54.0\lib\viewjpeg.ps -c (C:\Users\kbged\Pictures\group_image.jpg) viewJPEG

但是,这以以下错误结束:

GPL Ghostscript 9.54.0 (2021-03-30)
Copyright (C) 2021 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Error: /stackunderflow in --dup--
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--
Dictionary stack:
   --dict:732/1123(ro)(G)--   --dict:0/20(G)--   --dict:78/200(L)--   --dict:8/20(L)--
Current allocation mode is local
GPL Ghostscript 9.54.0: Unrecoverable error, exit code 1

我试图查看那个 viewjpeg.ps 文件,几乎看到了结尾


% This lets you do stuff on the command line like:
% gs -sDEVICE=pdfwrite -o stuff%03d.pdf viewjpeg.ps -c "(image.jpg) << /PageSize 2 index viewJPEGgetsize 2 array astore  >> setpagedevice viewJPEG"
% so the output size matches the original image.

我实际上不明白错误在哪里...... 任何帮助,将不胜感激!谢谢!

【问题讨论】:

    标签: pdf jpeg ghostscript


    【解决方案1】:

    有几种方法可以将图像转换为 PDF,这可能不是在 Ghostscript 中将 Jpeg 转换为 PDF 的最佳方法,但您问为什么它不适合您。

    以下 应该 在 cmd 文件中,首先按照示例工作,一旦证明,然后尝试更改您认为需要更改的最后一行的 。注意长线很脆弱,^后一定不能有空格

    此外,顺序和组合很容易使 GS 进入错误状态。 CMD 文件名最好始终使用“FullPath\quoted”,如果您不想将 CD 初始化到输出目录(以便更容易避免使用转义名称),请将最后一行的开头更改为

    -c "("C:\\Users\\kbged\\Pictures\\group_image.jpg") &lt;&lt;......

    注意更简单的方法是编写自己的 input.PS 以避免潜在的命令行截断。

    @echo off
    REM switch to folder of jpeg
    cd "C:\Users\kbged\Pictures"
    "C:\Users\kbged\Desktop\XAMPP\php\bin\gs\gs9.54.0\bin\gswin64c.exe" -dNOSAFER -sDEVICE=pdfwrite ^
    -o "C:\Users\kbged\Pictures\php48D4.pdf" "C:\Users\kbged\Desktop\XAMPP\php\bin\gs\gs9.54.0\lib\viewjpeg.ps" ^
    -c "(group_image.jpg) << /PageSize 2 index viewJPEGgetsize 2 array astore >> setpagedevice viewJPEG"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-27
      • 2013-09-13
      • 2017-03-02
      • 1970-01-01
      • 2015-02-19
      • 2012-09-08
      相关资源
      最近更新 更多