将一个 postscript 文件包含到另一个文件中?

发布于 2024-12-06 21:33:49 字数 345 浏览 1 评论 0 原文

我想知道是否有一种标准方法可以将一个 postscript 文件包含到另一个文件中。 例如,假设我有一个由第 3 方程序生成的数据文件:

%!PS
\mydata [ 1 2 3 4 5 6       
(...)
1098098
1098099
] def

并且我想将其包含到主 PS 文档中,

%PS
\processData
{
mydata { (..) } foreach
}

(...)

(data.ps) include %<=== ???

谢谢

I wonder if there a standard way to include a postscript file into another.
For example, say I have got one file of data generated by a 3rd party program:

%!PS
\mydata [ 1 2 3 4 5 6       
(...)
1098098
1098099
] def

and I would like to include it into a main PS document

%PS
\processData
{
mydata { (..) } foreach
}

(...)

(data.ps) include %<=== ???

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心碎无痕… 2024-12-13 21:33:49

您想要的运算符是run

字符串   运行   -      
执行指定文件的内容

不幸的是,如果解释器设置了 SAFER 选项,则不允许 run

编辑: Bill Casselman,《*数学插图》的作者有一个名为 psinc 您可以使用它来“预处理”您的 postscript 文件,内联所有 (...) run 文件。

The operator you want is run.

string   run   -      
execute contents of named file

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.

别想她 2024-12-13 21:33:49

我建议元解决方案:使用 C 预处理器或 M4 预处理器。它们是强大的工具,它们的功能还可以用于其他方面,而不仅仅是文件包含。虽然没有人要求这样做,但是使用 Makefile 来自动化整个工作流程是明智的。通过结合使用预处理器和 Makefile,您可以优雅地自动化复杂的包含处理等。

C 预处理器

包含文件:

#include "other.ps"

预处理命令行:

cpp -P main.pps main.ps

M4 预处理器

包含文件:

include(other.ps)

预处理命令行:

m4 main.pps > main.ps

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:

#include "other.ps"

Commandline for preprocessing:

cpp -P main.pps main.ps

M4 Preprocessor

Including a file:

include(other.ps)

Commandline for preprocessing:

m4 main.pps > main.ps
孤城病女 2024-12-13 21:33:49

包含 PostScript 的标准方法是将要包含的代码包含在 EPS(封装 PostScript)文件中。对于如何创建封装的 PostScript 以及如何包含它有一些规则。请参阅 Adob​​e 技术说明 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'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文