ghostscript and writing postscript in a c program.
by latticeguy from LinuxQuestions.org on (#4YWWH)
Hi,
I'm trying to write a postscript file in a c program. Most is working fine, but now I want
to include material from another file into the output. First I extract the page I want to
insert with
pstopdf -f page -l page -eps pdffile.pdf psfile.eps
Then in the program I have lines like
printf("save\n");
printf("(/pathtofile/psfile.eps) run \n");
printf("restore\n");
Then I proceed to write more postscript.
This works OK, although to see the file I must use "gv -nosafer myfile.ps"
But what I really want to do is have the inserted file fully included in postscript I write, not to be
included at the time the file is run. I tried replacing
printf("(/pathtofile/psfile.eps) run \n");
with
system("cat psfile.eps");
but this gives garbled results. I've tried using sed to remove the directives (lines starting with %%)
from the eps file, and this does work on some files, but not all.
Is there an accepted way to sneak one postscript file inside another?
Mike


I'm trying to write a postscript file in a c program. Most is working fine, but now I want
to include material from another file into the output. First I extract the page I want to
insert with
pstopdf -f page -l page -eps pdffile.pdf psfile.eps
Then in the program I have lines like
printf("save\n");
printf("(/pathtofile/psfile.eps) run \n");
printf("restore\n");
Then I proceed to write more postscript.
This works OK, although to see the file I must use "gv -nosafer myfile.ps"
But what I really want to do is have the inserted file fully included in postscript I write, not to be
included at the time the file is run. I tried replacing
printf("(/pathtofile/psfile.eps) run \n");
with
system("cat psfile.eps");
but this gives garbled results. I've tried using sed to remove the directives (lines starting with %%)
from the eps file, and this does work on some files, but not all.
Is there an accepted way to sneak one postscript file inside another?
Mike