open and save eps-files

Discussion in 'Java' started by McGregor, Jan 26, 2009.

  1. McGregor

    McGregor Guest

    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
    McGregor, Jan 26, 2009
    #1
    1. Advertising

  2. McGregor wrote:
    > 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
    Jeffrey H. Coffield, Jan 26, 2009
    #2
    1. Advertising

  3. McGregor

    McGregor Guest

    On 26 Jan., 15:17, "Jeffrey H. Coffield"
    <> wrote:

    > 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
    McGregor, Jan 27, 2009
    #3
  4. McGregor wrote:
    > On 26 Jan., 15:17, "Jeffrey H. Coffield"
    > <> wrote:
    >
    >> 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


    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.

    --
    RGB
    RedGrittyBrick, Jan 27, 2009
    #4
  5. McGregor wrote:
    > On 26 Jan., 15:17, "Jeffrey H. Coffield"
    > <> wrote:
    >
    >> 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


    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
    Jeffrey H. Coffield, Jan 27, 2009
    #5
  6. McGregor

    Roedy Green Guest

    On Mon, 26 Jan 2009 02:50:17 -0800 (PST), McGregor <>
    wrote, quoted or indirectly quoted someone who said :

    >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
    Roedy Green, Jan 28, 2009
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Hearn
    Replies:
    1
    Views:
    581
    Joel Leong
    Mar 5, 2005
  2. Susan Masters

    Viewing EPS in Java

    Susan Masters, Dec 5, 2003, in forum: Java
    Replies:
    1
    Views:
    3,925
    Marco Schmidt
    Dec 6, 2003
  3. Glen Pepicelli
    Replies:
    1
    Views:
    1,224
    Betty
    May 15, 2005
  4. John Henry

    Cut and paste an EPS file

    John Henry, Dec 2, 2005, in forum: Python
    Replies:
    4
    Views:
    1,457
    Piet van Oostrum
    Dec 3, 2005
  5. BusyBoy
    Replies:
    2
    Views:
    589
    =?Utf-8?B?TGVvbiBNYXluZQ==?=
    Oct 31, 2006
Loading...

Share This Page