【问题标题】:Ghostscript OS error "no such file or directory"Ghostscript 操作系统错误“没有这样的文件或目录”
【发布时间】:2020-07-04 23:17:06
【问题描述】:

尝试通过“运行”命令将外部 PostScript 文件导入另一个文件,如下所示:

(
save
%showpage {} bind def
("E:/My Documents/Development/Visual Studio 2017/Projects/ITL/SphereITL/SphereITL/ReportITL2/SphereItl/4_postscript/graphs.ps") run
restore)

目录和文件都正确。尝试了双反斜杠格式以及正斜杠,带引号和不带引号。还是报错。

我错过了什么?


这是 Ghostscript 的输出:

GSview 5.0 2012-01-17
GPL Ghostscript 9.52 (2020-03-19)
Copyright (C) 2020 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.
Displaying DSC file E:/My Documents/Development/Visual Studio 2017/Projects/ITL/SphereITL/SphereITL/ReportITL2/SphereItl/4_postscript/TM-30_Test1.PS
Displaying page 1
Loading NimbusSans-Regular font from %rom%Resource/Font/NimbusSans-Regular... 4376704 2870251 3628128 2298817 2 done.
Loading NimbusMonoPS-Regular font from %rom%Resource/Font/NimbusMonoPS-Regular... 4442816 3088087 3729128 2389676 2 done.
Loading C059-Italic font from %rom%Resource/Font/C059-Italic... 4670528 3335974 3749328 2397028 2 done.
Displaying page 2
Displaying page 3
Displaying page 4
Displaying page 5
Error: /undefined in @
Operand stack:
   (\nsave\n%showpage {} bind def\n\("E:/My Documents/Development/Visual Studio 2017/Projects/ITL/SphereITL/SphereITL/ReportITL2/SphereItl/4_postscript/graphs.ps"\) run\nrestore)
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   false   1   %stopped_push   1990   1   3   %oparray_pop   1989   1   3   %oparray_pop   1977   1   3   %oparray_pop   1833   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:744/1123(ro)(G)--   --dict:0/20(G)--   --dict:179/200(L)--
Current allocation mode is local
Last OS error: No such file or directory

--- Begin offending input ---
%%Page: 5  5

%%BeginPageSetup



showHeader

showNVLAPLogo

showFooter

gsave

% Formatting definitions



[ /Courier

 0.133

 10.00

  0.65   9.45

 (ABSOLUTE)

  0

  0

 [

(REPORT NUMBER:    TM-30_Test1                                       Page 5 of 6)

(DATE:             07/26/13)

(PREPARED FOR:     APPALACHIAN LIGHTING SYSTEMS, INC.)

(CATALOG NUMBER:   SL5-02 )

()

] ] prlines



(

save

%showpage {} bind def

("E:/My Documents/Development/Visual Studio 2017/Projects/ITL/SphereITL/SphereITL/ReportITL2/SphereItl/4_postscript/graphs.ps") run

restore)



@%showpage




--- End offending input ---
file offset = 13167
gsapi_run_string_continue returns -101

【问题讨论】:

  • ghostscript 是这样说的:第 5 页错误:“/undefined in @”所以删除 @。请阅读 Adob​​e 蓝皮书、绿皮书和红皮书以了解更多 PostScript。
  • 谢谢 - 我确实找到了 @ 字符并将其删除 - 文件/目录错误已解决,但我仍然无法使用运行命令显示外部 postscript 文件。

标签: ghostscript postscript


【解决方案1】:

首先你没有使用 Ghostscript,你使用的是 GSView。是的,GSView 使用 Ghostscript,但它添加了一堆“东西”,这会使事情变得更难。

无论如何,您遇到问题的原因几乎可以肯定是因为 Ghostscript 现在(自 9.50 起)默认为 SAFER 模式。

在 SAFER 模式下运行时,不允许 PostScript 解释器访问底层文件系统。显然,run 运算符需要访问文件系统才能执行外部 PostScript 程序。

Ghostscript 可执行文件确实会尝试将任何显然应该被允许的文件添加到允许的访问列表中。这包括(例如)在命令行中指定的输入文件。

在我们做出此更改之前多年就已发出信号,并记录在 9.50 的 release notes 中。

为了运行任意 PoostScript 文件,您需要将 -dNOSAFER 添加到 Ghostscript 命令行,或者专门将包含您要运行的文件的目录添加到允许的读取目录列表中。这记录在 SAFER here

【讨论】:

  • 好的 - 我会检查一下 - 谢谢 - 我是一个 C++ 人,不得不看一些后记,非常感谢你的帮助......
  • 仍然无法让它工作 - 可能没有正确实施。我尝试剪切和粘贴(我认为是).PS 文件的相关部分,它部分工作 - 在主文档中来回分页强制显示工作,尽管没有按照我想要的方式定位。不过,我想知道是否可以在主 postscript 文件中嵌入 PDF?
  • 不,绝对不是。 PostScript 根本不理解 PDF,将混合文件发送到 PostScript 解释器(如打印机),它会抛出错误。如果你得到了一些东西,那么它不是更安全的问题。如果没有看到 PostScript 程序,我没有其他建议。
  • 好的 - 谢谢 Ken - 你愿意看 PS 文件吗?我可以将它们发送给您 - 而不是在线发布公司专有材料...我将非常感谢您的洞察力和从中获得的知识...
  • 我当然可以试一试。你可以在“ken at spamcop dot net”给我发邮件(是的,它是一个真实的地址,如果比较老的话)。顺便说一句,我在这里的一天结束了(下午 5 点离开),所以我可能要到明天才能到达。
【解决方案2】:

删除文件名周围的引号。它们不是 Postscript 字符串语法的一部分。

save
%showpage {} bind def
(E:/My Documents/Development/Visual Studio 2017/Projects/ITL/SphereITL/SphereITL/ReportITL2/SphereItl/4_postscript/graphs.ps) run 
restore

【讨论】:

    猜你喜欢
    • 2020-01-13
    • 2021-08-05
    • 1970-01-01
    • 1970-01-01
    • 2021-07-10
    • 2017-11-29
    • 2020-02-15
    • 2020-08-10
    • 2021-06-24
    相关资源
    最近更新 更多