Ghostscript:堆栈下溢错误

Ghostscript: Stack Underflow Error

我正在尝试从相当大的文件生成 PDF PS。

运行:

/usr/bin/ps2pdf -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -dPDFSettings=/printer /home/sls/slspdf.tmp.8bcbd0365c30f4d287e416e8.ps

结果:

Error: /usr/bin/ps2pdf returned code 1: Error: /stackunderflow in --pop--
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1951   1   3   %oparray_pop   1950   1   3   %oparray_pop   1934   1   3   %oparray_pop   1820   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   1   1   5   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1186/1684(ro)(G)--   --dict:0/20(G)--   --dict:132/200(L)--   --dict:29/40(L)--
Current allocation mode is local
Last OS error: Not a directory
Current file position is 797649
GPL Ghostscript 9.15: Unrecoverable error, exit code 1

通过直接 gs(没有 ps2pdf 包装器)将其扔掉也不会产生太多有用的信息:

gs -sDEVICE=pdfwrite -o test.pdf - < /home/sls/slspdf.tmp.8bcbd0365c30f4d287e416e8.ps

输出:

GPL Ghostscript 9.15 (2014-09-22)
Copyright (C) 2014 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Can't find (or can't open) font file /usr/share/ghostscript/9.15/Resource/Font/NimbusMonL-Bold.
Can't find (or can't open) font file NimbusMonL-Bold.
Can't find (or can't open) font file /usr/share/ghostscript/9.15/Resource/Font/NimbusMonL-Bold.
Can't find (or can't open) font file NimbusMonL-Bold.
Querying operating system for font files...
Loading NimbusMonL-Bold font from /usr/share/fonts/default/Type1/n022004l.pfb... 4754536 3291634 8267744 6868788 1 done.
Loading NimbusMonL-Regu font from /usr/share/fonts/default/Type1/n022003l.pfb... 4797552 3426617 8463168 7042500 2 done.
Error: /stackunderflow in --pop--
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1951   1   3   %oparray_pop   1950   1   3   %oparray_pop   1934   1   3   %oparray_pop   1820   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   1   1   5   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1180/1684(ro)(G)--   --dict:0/20(G)--   --dict:132/200(L)--   --dict:29/40(L)--
Current allocation mode is local
Last OS error: Not a directory
GPL Ghostscript 9.15: Unrecoverable error, exit code 1

对我来说唯一可行的方法似乎是在物理上使输入文件更小……这当然不是一个非常可接受的解决方案。但是,我们可以编写脚本以生成几个 'pages' 的 PDF 输出,然后在第二遍中将它们附加在一起(如果这是最佳答案)。对这里的根本原因有什么想法吗?

我看到了一些关于 Last OS error: Not a directory 的信息,这只是最后一个 OS 的一般性错误,还是特别是从 Ghostscript 中抛出的?似乎它是通用的,因为截断文件使其工作,但我不知道。

忘记最后一个 OS 错误。

您的问题是您的 PostScript 程序有错误。 PostScript 是一种基于堆栈的语言,它告诉您您执行了 'pop' 运算符以从堆栈中删除顶部元素,并且堆栈为空。

没有看到 PostScript 程序,我不能说更多。可能它以某种方式损坏了。