当手写Postscript代码时,Ghostscript出现未定义错误。

3

我已经有大约20年没有手写Postscript了,所以我打开了Bluebook并将一些示例输入到名为test.ps的文件中。以下就是其中一个示例:

%!PS
/doACircle
{ 0 0 54 0 360 arc stroke } def
/doAnEllipse
{ 1 .75 scale
doACircle
stroke } def
300 500 translate doACircle
4 {0 −72 translate
doAnEllipse} repeat
showpage

我正在一个Debian Linux系统中使用Ghostscript和Imagemagick。它们之前的工作都很好。当我运行下面这个命令时:

convert test.ps test.png

我遇到了一个错误并且输出了一份转储:

Error: /undefined in 
Operand stack:
   0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1992   1   3   %oparray_pop   1991   1   3   %oparray_pop   1979   1   3   %oparray_pop   1833   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   3   --nostringval--   %repeat_continue   --nostringval--
Dictionary stack:
   --dict:727/1123(ro)(G)--   --dict:0/20(G)--   --dict:78/200(L)--
Current allocation mode is local
Current file position is 167
GPL Ghostscript 9.27: Unrecoverable error, exit code 1
Error: /undefined in 
Operand stack:
   0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1992   1   3   %oparray_pop   1991   1   3   %oparray_pop   1979   1   3   %oparray_pop   1833   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   3   --nostringval--   %repeat_continue   --nostringval--
Dictionary stack:
   --dict:727/1123(ro)(G)--   --dict:0/20(G)--   --dict:78/200(L)--
Current allocation mode is local
Current file position is 167
GPL Ghostscript 9.27: Unrecoverable error, exit code 1
convert-im6.q16: no images defined `test.png' @ error/convert.c/ConvertImageCommand/3258.

我知道我忘了某些基础内容 - 也许是与边界框相关的内容?

1个回答

3

程序流中出现了奇怪的字符。我猜测你在使用Macintosh,并且键盘处理程序正在用某个外表上更加合适的破折号字符替换连字符。这会创建一个畸形的负数,它被解析为名称……然后就没有在字典堆栈中定义这样的名称。

以下是错误信息中可以帮助解决类似问题的一些线索:

  • /undefined 错误是字典查找失败的结果。这可能发生在 loadknownget 或自动查找程序流中可执行名称的情况下。
  • 操作数堆栈转储显示单个 0,因此它必须发生在堆栈上有一个单个 0 的位置。
  • 表示GS遇到了一个它不知道该如何处理的字符。

2
天啊,现在我感觉像个傻瓜。我正在从《蓝书》的PDF版本复制文本,其中连字符是印刷破折号。替换它们修复了问题。非常感谢。 - Ed S.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接