开发者

Including a postscript file into another one?

I wonder if there a standard way to include开发者_如何学Go 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


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.


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'.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜