PostScript:无法执行包含 "run" 命令的宏
PostScript: not able to execute a macro containing "run" command
尝试制作一些我以后可以使用的 PostScript 函数,我需要将这些函数(PostScript 术语中的过程)存储在单独的文件中。有一个运行命令
(foo.bar) run
您可以使用它。但我无法让它工作。
这是函数示例 (itopc.ps):
% this function converts inches to points
/itopc {72 mul} def
这是主脚本的示例 (from here):
%!
(itopc.ps) run
newpath
1 itopc 2 itopc moveto
200 250 lineto
100 300 lineto
2 setlinewidth
stroke
showpage
这是我在 windows 10:
上使用 gsview 时遇到的错误
Error: /invalidfileaccess in --run--
Operand stack:
(itopc.ps) (r)
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- false 1 %stopped_push 1983 1 3 %oparray_pop 1982 1 3 %oparray_pop 1966 1 3 %oparray_pop 1852 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- 1983 1 3 %oparray_pop --nostringval--
Dictionary stack:
--dict:1212/1684(ro)(G)-- --dict:0/20(G)-- --dict:82/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
--- Begin offending input ---
主要代码然后
--- End offending input ---
file offset = 0
gsapi_run_string_continue returns -101
P.S。看起来 Ghostscript 能够 运行 这个 script/macro,非常好。但是 GSview 和 mac OS X automatic Preview ps to pdf converter 不能这样做!
这是文档处理的典型配置。对于 ghostscript,您可以将 -dNOSAFER
添加到命令行以重新启用 run
运算符。在 GSview 中,您可以进入选项并将其添加到 gs 命令中。不确定如何使用预览来完成。
我想我已经解决了这个问题。正如 this page 所解释的那样,出于安全原因,许多官方 PostScript 解释器不支持 "run" 命令。至少 Apple Preview 和 Adobe 产品没有。但是 GhosScript 可以。您可以使用命令打开文件:
gs foo.ps
在类似 unix 的机器上和在 Windows 机器上你可以使用 PS_View app installed with Ghostscript or Samutrapdf
将 ps2pdf 作为 this post explains 您可以使用以下命令编译 PDF:
ps2pdf -dNOSAFER foo.ps
对于 GSView,在 Windows 上,您可以转到“选项”>“高级配置...”并添加
-dNOSAFE
到 GhostScript 选项。
尝试制作一些我以后可以使用的 PostScript 函数,我需要将这些函数(PostScript 术语中的过程)存储在单独的文件中。有一个运行命令
(foo.bar) run
您可以使用它。但我无法让它工作。 这是函数示例 (itopc.ps):
% this function converts inches to points
/itopc {72 mul} def
这是主脚本的示例 (from here):
%!
(itopc.ps) run
newpath
1 itopc 2 itopc moveto
200 250 lineto
100 300 lineto
2 setlinewidth
stroke
showpage
这是我在 windows 10:
上使用 gsview 时遇到的错误Error: /invalidfileaccess in --run--
Operand stack:
(itopc.ps) (r)
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- false 1 %stopped_push 1983 1 3 %oparray_pop 1982 1 3 %oparray_pop 1966 1 3 %oparray_pop 1852 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- 1983 1 3 %oparray_pop --nostringval--
Dictionary stack:
--dict:1212/1684(ro)(G)-- --dict:0/20(G)-- --dict:82/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
--- Begin offending input ---
主要代码然后
--- End offending input ---
file offset = 0
gsapi_run_string_continue returns -101
P.S。看起来 Ghostscript 能够 运行 这个 script/macro,非常好。但是 GSview 和 mac OS X automatic Preview ps to pdf converter 不能这样做!
这是文档处理的典型配置。对于 ghostscript,您可以将 -dNOSAFER
添加到命令行以重新启用 run
运算符。在 GSview 中,您可以进入选项并将其添加到 gs 命令中。不确定如何使用预览来完成。
我想我已经解决了这个问题。正如 this page 所解释的那样,出于安全原因,许多官方 PostScript 解释器不支持 "run" 命令。至少 Apple Preview 和 Adobe 产品没有。但是 GhosScript 可以。您可以使用命令打开文件:
gs foo.ps
在类似 unix 的机器上和在 Windows 机器上你可以使用 PS_View app installed with Ghostscript or Samutrapdf
将 ps2pdf 作为 this post explains 您可以使用以下命令编译 PDF:
ps2pdf -dNOSAFER foo.ps
对于 GSView,在 Windows 上,您可以转到“选项”>“高级配置...”并添加
-dNOSAFE
到 GhostScript 选项。