Another way to achieve this would be to hack the postscript file itself. It used to be that AI files are postscript files, and you can modify them directly; I do not know if this is true. Therefore, you may have to export it.
For simplicity, I assume one page. Therefore, at the very end there will be one call to showpage
(possibly through a different name). Any drawing commands executed before displaying will be displayed on the page.
You may need to reinitialize the state of the graphics ( initgraphics
), as the rest of the document may have left it funny, waiting for the showpage to clear before anyone notices.
To accommodate the text, you will need to install a new font (the old initgraphics was canceled) to measure the location in points (72 dpi, 28.3465 dots / cm).
/Palatino-Roman 17 selectfont %so much prettier than Times xy moveto (new text) show
To perform a merge, you can use perl: emit the beginning of the document as an HERE document, construct some text lines in the program, emit the tail of the document. Here is an example postscript generation with PERL
Or you can take data from the command line (using ghostscript) using the --
parameter ( $gs -q -- program.ps arg1 arg2 ... argn
). These arguments are available to the program through an array named / ARGUMENTS.
So, let's say you have good graphics of a scary clown holding a blank sign about 1 inch wide, 3 inches high, the top left corner 4 inches to the left, 4 inches from the base. You can paste this code into the ps program just before the showpage
.
initgraphics /Palatino-Roman 12 selectfont 4 72 mul 4 72 mul moveto ARGUMENTS { gsave show grestore 0 -14 rmoveto } forall
Now you can make him say funny things ( $gs -- clown.ps "On a dark," "and stormy night..."
).