尝试制作一些我以后可以使用的PostScript函数,我需要将这些函数(PostScript术语中的进程)存储在单独的文件中。有一个运行命令
(foo.bar)运行
你可以这样做。但是我无法让它发挥作用。 这是一个函数示例(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这样的接缝能够运行这个脚本/宏,完全没问题。但是GSview和mac OS X自动预览ps到pdf转换器都无法做到!
答案 0 :(得分:1)
这是文档处理的典型配置。对于ghostscript,您可以在命令行中添加-dNOSAFER
以重新启用run
运算符。在GSview中,您可以进入选项并将其添加到gs命令。不确定如何使用预览。
答案 1 :(得分:0)
我想我已经解决了这个问题。正如this page所解释的那样,许多官方PostScript解释器都不支持" run"出于安全原因的命令。至少Apple Preview和Adobe产品没有。但是GhosScript可以。您可以使用命令打开文件:
gs foo.ps
在unix上的机器和Windows机器上,您可以使用随Ghostscript安装的PS_View应用程序或Samutrapdf
ps2pdf为this post explains,您可以使用以下命令编译PDF:
ps2pdf -dNOSAFER foo.ps
对于GSView,在Windows上,您可以转到选项>高级配置...并添加
-dNOSAFE
到GhostScript选项。