将一个 postscript 文件包含到另一个文件中?
我想知道是否有一种标准方法可以将一个 postscript 文件包含到另一个文件中。 例如,假设我有一个由第 3 方程序生成的数据文件:
%!PS
\mydata [ 1 2 3 4 5 6
(...)
1098098
1098099
] def
并且我想将其包含到主 PS 文档中,
%PS
\processData
{
mydata { (..) } foreach
}
(...)
(data.ps) include %<=== ???
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您想要的运算符是
run
。不幸的是,如果解释器设置了 SAFER 选项,则不允许
run
。编辑: Bill Casselman,《*数学插图》的作者有一个名为 psinc 您可以使用它来“预处理”您的 postscript 文件,内联所有
(...) run
文件。The operator you want is
run
.Unfortunately,
run
is not allowed if the interpreter has the SAFER option set.Edit: Bill Casselman, author of *Mathematical Illustrations" has a Perl script called psinc you can use to "preprocess" yor postscript files, inlining all
(...) run
files.我建议元解决方案:使用 C 预处理器或 M4 预处理器。它们是强大的工具,它们的功能还可以用于其他方面,而不仅仅是文件包含。虽然没有人要求这样做,但是使用 Makefile 来自动化整个工作流程是明智的。通过结合使用预处理器和 Makefile,您可以优雅地自动化复杂的包含处理等。
C 预处理器
包含文件:
预处理命令行:
M4 预处理器
包含文件:
预处理命令行:
I would suggest meta-solution: use C preprocessor or M4 preprocessor. They are powerful tools and their power may find use in other ways as well, not only file inclusion. Though this was not asked, but use of Makefile will be wise to automate whole workflow. By using a preprocessor and Makefile in combination you can elegantly automate complex inclusions processing and beyond.
C Preprocessor
Including a file:
Commandline for preprocessing:
M4 Preprocessor
Including a file:
Commandline for preprocessing:
包含 PostScript 的标准方法是将要包含的代码包含在 EPS(封装 PostScript)文件中。对于如何创建封装的 PostScript 以及如何包含它有一些规则。请参阅 Adobe 技术说明 5002“封装的 PostScript 文件格式规范”
简单地对 PostScript 文件执行“运行”可能会很好,但也可能会导致问题。许多 PostScript 文件(尤其是第三方生成的文件)将包含可能与您自己的名称冲突的过程定义,并且包含的程序可能会使解释器处于与执行包含的文件时不同的状态。至少您应该围绕通过“运行”包含的代码执行保存/恢复对。
The standard way to include PostScript is to make the code to be included an EPS (Encapsulated PostScript) file. There are rules on how encapsulated PostScript must be created, and how to include it. See Adobe Tech Note 5002 'Encapsulated PostScript File Format Specification'
Simply executing 'run' on a PostScript file may well work, but it might also cause problems. Many PostScript files (especially those produced by 3rd parties) will include procedure definitions which may clash with your own names, and also the included program may leave the interpreter in a state different from the one it was in when the included file was executed. At the very least you should execute a save/restore pair around the code included via 'run'.