open and save eps-files

M

McGregor

Hello everyone,

I need some help finding a solution for my problem.
I only need to open several eps-file (made with Illustrator-CS3),
arrange them on a new canvas and save them again as an eps-file.
That's it.

I tried several libraries but I failed cos they aren't able to open
eps-files.
Some said it could be done with ghostscript, but how is it done?

I have some experience in creating pdf-files using the commercial
installation of pdflib, so converting the eps to pdf and then
arranging them on a pdf and after that converting back to eps would be
also a possible solution - but not preferred.

Any hint would be nice... and btw. Java isn't really necessary. It
could also any other language.

Thanks in advance
Jens
 
J

Jeffrey H. Coffield

McGregor said:
Hello everyone,

I need some help finding a solution for my problem.
I only need to open several eps-file (made with Illustrator-CS3),
arrange them on a new canvas and save them again as an eps-file.
That's it.

I tried several libraries but I failed cos they aren't able to open
eps-files.
Some said it could be done with ghostscript, but how is it done?

I have some experience in creating pdf-files using the commercial
installation of pdflib, so converting the eps to pdf and then
arranging them on a pdf and after that converting back to eps would be
also a possible solution - but not preferred.

Any hint would be nice... and btw. Java isn't really necessary. It
could also any other language.

Thanks in advance
Jens

A simple Postscript program can do that. I can provide a sample if you want.

Jeff Coffield
www.digitalsynergyinc.com
 
M

McGregor

A simple Postscript program can do that. I can provide a sample if you want.

You are kidding?
Really?
This would be very nice if you pass me a sample.
And thanks for your help.

Jens
 
R

RedGrittyBrick

McGregor said:
You are kidding?
Really?
This would be very nice if you pass me a sample.
And thanks for your help.

Jens

Postscript is a programming language.
Here's an EPS file:

-----------------------------8<----------------------------------
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 18 108 594 684
%%EndComments
/inch { 72 mul } def
%%EndProlog
1 inch setlinewidth
4.25 inch 5.5 inch 3.5 inch 0 360 arc closepath 0.66 setgray stroke
4.25 inch 5.5 inch 2.5 inch 0 360 arc closepath 0.50 setgray stroke
4.25 inch 5.5 inch 1.5 inch 0 360 arc closepath 0.33 setgray stroke
4.25 inch 5.5 inch 0.5 inch 0 360 arc closepath 0.00 setgray stroke
%%EOF
-----------------------------8<----------------------------------


Here's how you'd encapsulate that in a PS file that positions the EPS

-----------------------------8<----------------------------------
%!PS

/Times-Roman findfont 22 scalefont setfont
250 790 moveto (Testing EPS) show

420 740 moveto (X) show % where we want EPS BL

%
% start of encapsulation
% standard preamble to neutralise any statements in EPS that might
% cause problems.
%
save
/showpage {} def
/erasepage {} def
/copypage {} def
0 setgray
0 setlinecap
1 setlinewidth
0 setlinejoin
10 setmiterlimit
[] 0 setdash
/languagelevel where {
pop
languagelevel 2 ge {
false setoverprint
false setstrokeadjust
} if
} if
newpath
%
% reposition and resize the EPS image
%
420 740 translate % where we want EPS BL
0.2 0.2 scale
% ----------------------------------------------------
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 18 108 594 684
%%EndComments
/inch { 72 mul } def
%%EndProlog
1 inch setlinewidth
4.25 inch 5.5 inch 3.5 inch 0 360 arc closepath 0.66 setgray stroke
4.25 inch 5.5 inch 2.5 inch 0 360 arc closepath 0.50 setgray stroke
4.25 inch 5.5 inch 1.5 inch 0 360 arc closepath 0.33 setgray stroke
4.25 inch 5.5 inch 0.5 inch 0 360 arc closepath 0.00 setgray stroke
%%EOF
% ----------------------------------------------------
restore
%
% end of encapsulation
%

250 090 moveto ((TestEPS.ps)) show
showpage
-----------------------------8<----------------------------------

You might create the latter from the former by writing a Java program
that reads text files (a.eps, b.eps c.eps) which contain EPS and writes
a text file (all.ps) containing a PS program that encapsulates the EPS
images at desired positions on a page.

AFAIK some EPS files can contain binary. You'd have to take that into
account when writing a program to read and write EPS.

Your question is more about Postscript than about Java. There is a
Postscript newsgroup.
 
J

Jeffrey H. Coffield

McGregor said:
You are kidding?
Really?
This would be very nice if you pass me a sample.
And thanks for your help.

Jens

Jens,

Attached is a sample test.ps and test.eps. Note that the file test.eps
contains a "showpage" which would normally cause the page to print and
is not at all unusual in an EPS file. The BeginEPSF and EndEPSF takes
care of preventing this from happening.

Jeff
 
R

Roedy Green

I need some help finding a solution for my problem.
I only need to open several eps-file (made with Illustrator-CS3),
arrange them on a new canvas and save them again as an eps-file.
That's it.

I tried several libraries but I failed cos they aren't able to open
eps-files.
Some said it could be done with ghostscript, but how is it done?

I have some experience in creating pdf-files using the commercial
installation of pdflib, so converting the eps to pdf and then
arranging them on a pdf and after that converting back to eps would be
also a possible solution - but not preferred.

Any hint would be nice... and btw. Java isn't really necessary. It
could also any other language.

eps files are just PostScript text files with a summary header. If you
know PostScript, you can create a skeleton into which you pour the
documents. You then need to generate a new header and save as EPS.

PostScript is very flexible in the way you can prefix code with
commands to translate the origin and change the scaling.

I suggest you find some simple little postscript programs -- e.g. that
draw a ball, square, write a line of text etc. and then write the code
to put them into the format you want. Then write some code to glue the
pieces together.

You can debug as you go by printing on a PS printer, or interpreting
with Ghostscript.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Here is a point of no return after which warming becomes unstoppable
and we are probably going to sail right through it.
It is the point at which anthropogenic (human-caused) warming triggers
huge releases of carbon dioxide from warming oceans, or similar releases
of both carbon dioxide and methane from melting permafrost, or both.
Most climate scientists think that point lies not far beyond 2°C (4°F) C hotter."
~ Gwynne Dyer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top