[comp.lang.postscript] Converting PS to EPS

dalessio@motcid.UUCP (Mario D'Alessio) (04/03/91)

I have a postscript file (extracted from a previoulsly posted
file containing different logos. Apologies to the creator) which
prints the "Star Trek: The Next Generation" logo. I converted it
to an EPS file to pull into a desktop publishing program (Interleaf
on a Sun). When I try to print it, I get the following error message
from the printer log file:

   %%[ Error: invalidrestore; OffendingCommand: restore ]%%
   %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%

Can anyone tell me what causes this? I have printed EPS files
before with no problems. Or maybe I can get a copy of the logo
already as an EPS file.

I can email the PS and/or the EPS file. I don't want to include them
here because they are around 800 lines each in size.

ANY HELP APPRECIATED! Thanks in advance!

******************************************************************
* ************************************************************** *
* *                                                            * *
* *  Mario D'Alessio            Motorola, Inc.                 * *
* *  dalessio@motcid.UUCP       Cellular Infrastructure Group  * *
* *                                                            * *
* ************************************************************** *
******************************************************************

rel@mtu.edu (Robert Landsparger) (04/03/91)

In article <6119@crystal8.UUCP>, dalessio@motcid.UUCP (Mario D'Alessio) writes:
|> I have a postscript file (extracted from a previoulsly posted
|> file containing different logos. Apologies to the creator) which
|> prints the "Star Trek: The Next Generation" logo. I converted it
|> to an EPS file to pull into a desktop publishing program (Interleaf
|> on a Sun). When I try to print it, I get the following error message
|> from the printer log file:
|> 
|>    %%[ Error: invalidrestore; OffendingCommand: restore ]%%
|>    %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
|> 
|> Can anyone tell me what causes this? I have printed EPS files
|> before with no problems. Or maybe I can get a copy of the logo
|> already as an EPS file.

I ran into this problem also with a PS file that I wrote.  I am not
sure what the problem was, but I worked up a "walk-around".  I'll
do my best to explain it.  This is done to the original PS file, before
you do the PS->EPS conversion.  You need to add a 'mark' and a 'cleartomark'
around the "script" portion of you PS file.  ie:

-----------------------------------------

%!
%%BeginProlog
/aprocedure { pop } def
/bprocedure { pop } def
%%EndProlog
%%BeginProcSet

mark                     %% this is added

1 aprocedure
2 bprocedure

showpage

cleartomark              %% this is added

%%Trailer

------------------------------------------

Hope this will be of help.  
	--bob

-- 

USER:		Can I get a list of *all* the unix commands?
CONSULTANT:	man -k - | lpr -
USER:		huh?

+-------------------------------------------------------------------------+
| Robert E. Landsparger (rel@mtu.edu) - Computing Technology Services
| Michigan Technological University, Houghton, MI 49931	(906) 487-2110
+--------------------------------------------------------------------+
| The above comments do not always represent those of my employer.
+

brown@vidiot.UUCP (Vidiot) (04/04/91)

In article <6119@crystal8.UUCP> dalessio@motcid.UUCP (Mario D'Alessio) writes:
<I have a postscript file (extracted from a previoulsly posted
<file containing different logos. Apologies to the creator) which
<prints the "Star Trek: The Next Generation" logo. I converted it
<to an EPS file to pull into a desktop publishing program (Interleaf
<on a Sun). When I try to print it, I get the following error message
<from the printer log file:
<
<   %%[ Error: invalidrestore; OffendingCommand: restore ]%%
<   %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
<
<Can anyone tell me what causes this? I have printed EPS files
<before with no problems. Or maybe I can get a copy of the logo
<already as an EPS file.

The logos in the PostScript document were not meant for EPS use.  You need
to get the EPS files that have been posted just for this use.  Check the
ftp sites, as they should be there.  Instructions have been posted in the past.
-- 
      harvard\     att!nicmad\          spool.cs.wisc.edu!astroatc!vidiot!brown
Vidiot  ucbvax!uwvax..........!astroatc!vidiot!brown
      rutgers/  decvax!nicmad/ INTERNET:vidiot!brown%astroatc@spool.cs.wisc.edu

brown@vidiot.UUCP (Vidiot) (04/04/91)

In article <1991Apr3.090403.13355@mtu.edu> rel@mtu.edu (Robert Landsparger) writes:
<In article <6119@crystal8.UUCP>, dalessio@motcid.UUCP (Mario D'Alessio) writes:
<|> I have a postscript file (extracted from a previoulsly posted
<|> file containing different logos. Apologies to the creator) which
<|> prints the "Star Trek: The Next Generation" logo. I converted it
<|> to an EPS file to pull into a desktop publishing program (Interleaf
<|> on a Sun). When I try to print it, I get the following error message
<|> from the printer log file:
<|> 
<|>    %%[ Error: invalidrestore; OffendingCommand: restore ]%%
<|>    %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
<|> 
<|> Can anyone tell me what causes this? I have printed EPS files
<|> before with no problems. Or maybe I can get a copy of the logo
<|> already as an EPS file.
<
<I ran into this problem also with a PS file that I wrote.  I am not
<sure what the problem was, but I worked up a "walk-around".  I'll
<do my best to explain it.  This is done to the original PS file, before
<you do the PS->EPS conversion.  You need to add a 'mark' and a 'cleartomark'
<around the "script" portion of you PS file.  ie:

Not necessary.  The logos in the document were first done as standalone
and then converted to EPS and then incorporated into the program guide.
When they were incorporated into the guide, pieces were moved around, making
it hard to put back into an EPS file.
-- 
      harvard\     att!nicmad\          spool.cs.wisc.edu!astroatc!vidiot!brown
Vidiot  ucbvax!uwvax..........!astroatc!vidiot!brown
      rutgers/  decvax!nicmad/ INTERNET:vidiot!brown%astroatc@spool.cs.wisc.edu

bchen@argon.berkeley.edu (Benjamin Chen) (04/05/91)

My mail bounced so I'm posting instead:

Can someone tell me what utility they used to convert PS tp EPS and how
to get a hold of it?

	Thanks, in advance,

	BC


--
--------------------------------------------------------------------------------
Benjamin Chen  
Electronics Research Laboratory   550-A4 Cory Hall, University of California
(bchen@argon.Berkeley.EDU,  ...!ucbvax!argon!bchen)        

diana@er.ARCO.COM (Diana Sparks) (04/06/91)

In article <6119@crystal8.UUCP>, dalessio@motcid.UUCP (Mario D'Alessio)
writes:
> I have a postscript file (extracted from a previoulsly posted
> file containing different logos. Apologies to the creator) which
> prints the "Star Trek: The Next Generation" logo. I converted it
> to an EPS file to pull into a desktop publishing program (Interleaf
> on a Sun). When I try to print it, I get the following error message
> from the printer log file:
> 
>    %%[ Error: invalidrestore; OffendingCommand: restore ]%%
>    %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
> 


No answer, just another question: (I have read the follow-ups to
this post, and since I am using a totally different EPS file and
am getting a similar message, I have a feeling it's a file -> 
Interleaf problem.)

I am currently working on an Interleaf (on Sun Sparc)
doc that has Illustrator files converted to EPS and 
I am getting a similar message on some of them 
(not all, which really makes it confusing!)

My message says:

	%%[ Error: undefined; OffendingCommand: mfx ]%%
	%%[ Flushing: rest of job (to end-of-file) will be ignored ]%%

And, FYI, this file prints just fine from Adobe Illustrator to 
the LaserWriter via the Mac, so I am wondering if 
the sticking-point is with the Interleaf software? 

I have compared the file that won't print to the ones that 
will and really can't see any difference, but I am by no 
means a postscript guru at all.  

Anybody have any other ideas?

(ps: I tried to e-mail to you, Mario, but the mail bounced.)

Thanks.

-- 
$ 
<<<<<<<<<<>>>>>>>>>>>><<<<<<<<<<<<>>>>>>>>>>>><>>>>>>>>>><<<<<
<><>  Diana Sparks-->>                 diana@er.arco.com <><><
<><>  "This is very simple: first you access your mainframe...
<><>  or "on" to the computer illiterate." The Wizard: 'Shoe'.
<<<<<<<<<<>>>>>>>>>>>><<<<<<<<<<<<>>>>>>>>>>>><>>>>>>>>>><<<<<
$

-- 
$ banner
<<<<<<<<<<>>>>>>>>>>>><<<<<<<<<<<<>>>>>>>>>>>><>>>>>>>>>><<<<<
<><>  Diana Sparks-->>                 diana@er.arco.com <><><
<><>  "This is very simple: first you access your mainframe...
<><>  or "on" to the computer illiterate." The Wizard: 'Shoe'.
<<<<<<<<<<>>>>>>>>>>>><<<<<<<<<<<<>>>>>>>>>>>><>>>>>>>>>><<<<<
$

barker@Software.Mitel.COM (John Barker) (04/12/91)

In article <1991Apr5.205947.607@Arco.COM>, diana@diana (Diana Sparks)
writes:

>In article <6119@crystal8.UUCP>, dalessio@motcid.UUCP (Mario D'Alessio)
>writes:
>> I have a postscript file (extracted from a previoulsly posted
>> file containing different logos. Apologies to the creator) which
>> prints the "Star Trek: The Next Generation" logo. I converted it
>> to an EPS file to pull into a desktop publishing program (Interleaf
>> on a Sun). When I try to print it, I get the following error message
>> from the printer log file:
>> 
>>    %%[ Error: invalidrestore; OffendingCommand: restore ]%%
>>    %%[ Flushing: rest of job (to end-of-file) will be ignored ]%% 
>
[stuff deleted]

>And, FYI, this file prints just fine from Adobe Illustrator to 
>the LaserWriter via the Mac, so I am wondering if 
>the sticking-point is with the Interleaf software? 
>
>I have compared the file that won't print to the ones that 
>will and really can't see any difference, but I am by no 
>means a postscript guru at all.  
>
>Anybody have any other ideas?

Interleaf (TPS 4.0) does not handle EPS well. There have been several 
problems in our environment related to EPS files originating from
Corel Draw imported into Interleaf. In this case, Interleaf recommended
the following work-around:

- paste the EPS file into your Interleaf graphic frame and position it
  and size as required.
- draw a box (Interleaf graphic) around the EPS file, sized exactly to it.
- cut the EPS file, then re-paste it into the document, placing it in the
  box previously drawn.
- the box must have properties set visible->yes, but can have color->white.

In most cases, the EPS file then prints correctly (odd, but true). What I think
happens is that the EPS file gets nested inside the graphic frame incorrectly
unless some previous graphic object was there to contain it.

As for the "OffendingCommand" error, I have seen it even generated because
the PostScript interpreter was being fed text from the Interleaf document,
not the PostScript code -- that is, text strings from the document were
getting incorrectly embedded in the PostScript master, because of the EPS file.
Removing the EPS file solves the problem, so I suspect the EPS file is 
not terminating correctly in the Interleaf PostScript master. Somehow the
above work-around fixes it (in most cases). I haven't looked closely at
the EPS files in Interleaf's PostScript master yet, though, to determine why.

We are running TPS version 4.0.95, on Sun 3/60s and 3/80s, SunOS 4.0.3.,
printing to QMS, Sun, NEC and Kodak printers, and to Linotron typsetters.

I haven't heard of any TPS 4.0 patch to fix this. 

--john

Bjorn.B.Larsen@delab.sintef.no (Bjoern Larsen) (05/24/91)

Can anybodcy help me converting a PostScript file to Encapsulated PostScript??

Our schematic entry system produces plot-files in PostScript, but to be able to
include a figure in LaTeX I need Encapsulated PostsScript.

I have tried modifying the file by adding a BoundingBox, but that is obviously
not sufficient.  It looks OK with Preview, (but that does not read the
.eps-part, only the space needed)  When I try to print the resulting file,
from the start of the page to, and including, the figure dissappear.  The text
following the figure prints OK, and in the right place.

Does anybody have a suggestion??

Thanks.

\Bjorn B. Larsen

orthlieb@adobe.COM (Carl Orthlieb) (05/29/91)

There is a PostScript program available on our mail server called 'epsfinfo.ps'
that should do what you want.  You tack it onto the head of your PS file 
and then send it down to the printer using SendPS or LaserTalk.  You will 
then get back the bounding box and font usage info for your PS file.  If
you then change the top of your file to read:
	%!PS-Adobe-3.0 EPSF-3.0
	%%BoundingBox: <llx> <lly> <urx> <ury>
	%%DocumentFonts: <font1> <font2> <font3> ...
you should then have an EPS file (w/o a preview). <llx>, <lly>, <urx>, and
<ury> are the bounding box values sent back by the epsfinfo program (make
sure that these are integer values). <font1>, <font2>, <font3>, etc.
are the names of the fonts used by your file (e.g. Times-Roman).

Note that there are some PS operators that should not be used in an
EPS file.  The epsfinfo program will notify you if your PS file uses
these operators.  See Appendix I of the new red book for more info.

Hope this helps, Carl 8-)

P.S. You probably want to send our server a message with the following line
in it:

send Programs epsfinfo.ps

----------- Server Access Information -----------
The PS-File-Server is an automatic mail-response program. That means you
mail it a request, and it mails back the response. It is not accessible 
via anonymous FTP.

To get in touch with the server, send a message to the appropriate address,
either:
	uucp: {sun,decwrl}!adobe!ps-file-server OR
	internet: ps-file-server@adobe.COM
containing the word "help" in either the Subject: field or the message body.
It will reply with a message on how to use the available services.

There are many items available from the server; Documents (as PostScript
files), program sources, Adobe Font Metrics files, PostScript Printer
Description files, and other itmes.

You might send a separate message containing the word "index" to save some
time once you get the help message.

The file server does not respond to requests from users named "root",
"system", "daemon", or "mailer". This is to prevent mail loops from bounced
messages.

Note: If you do not receive help from the server within a day or so, it is
probably because the server's mail to you has bounced. You can try again
and use the "path" command within your message specifying a known return
path that the server should use. For example:
	path pyramid!rutgers!zakkaroo!jj
(substitute whatever address is appropriate)

If you have any problems contacting the server, or you have any suggestions,
please send a message to the moderator (ps-file-person@adobe.COM).

Carl 8-) 

aas@aase.nr.no (Gisle Aas) (05/29/91)

In article <15708@adobe.UUCP> orthlieb@adobe.COM (Carl Orthlieb) writes:
>   you should then have an EPS file (w/o a preview).

And if you want to have an EPS file WITH a preview, and you have
GhostScript, and you have perl, then you can try to filter the file
through the following program.

Enjoy!

------cut here-----
#!/usr/local/bin/perl
'di';
'ig00';

# EPSI file generator. Written by Gisle Aas, NR, 1991
# Converts all types of EPS-files to the EPSI format where a bitmap preview
# is included. You need GhostScript to render the bitmaps for you.

# $Log: eps2epsi,v $
# Revision 1.1  1991/05/28  09:18:04  aas
# Initial revision
#

$prog_name = substr($0,rindex($0,"/")+1);
require 'getopts.pl';
unless (&Getopts('w:')) {
  print STDOUT "Usage: $prog_name [-w <preview width>] [<file>]\n";
  exit 1;
}

die 'To many files' if ($#ARGV > 0);

@epsfile = <>;			# slurp
die 'Not PostScript file' unless ($epsfile[0] =~ /^%!PS-Adobe-/);

# Get the dimensions of the picture
for (@epsfile) {
   ($llx, $lly, $urx, $ury) =
       /^%%BoundingBox:\s*(-?\d+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)/;
   last if defined($llx);
}
die 'No %%BoundingBox found in file' unless defined($llx);

# Calculate 
$preview_width = int(($opt_w || 79) / 2) * 8;
$width  = $urx - $llx + 1;
$height = $ury - $lly + 1;
$scalefactor = $preview_width / $width;
$width  = int($width * $scalefactor);
$height = int($height * $scalefactor);

# Produce GhostScript program
$gsfile = "/tmp/gs$$.tmp";
open(GSFILE, ">$gsfile") || die "Can't write to file $gsfile";
print GSFILE <<"---EndGhostScriptProgram---";
%!GhostScript
/BITIMAGE_WIDTH $width def
/BITIMAGE_HEIGHT $height def
/BITIMAGE_FILE (%stdout) def

%---- Setup a memory device --------
[1 0 0 -1 0 BITIMAGE_HEIGHT]
BITIMAGE_WIDTH BITIMAGE_HEIGHT
[1 1 1 rgbcolor 0 0 0 rgbcolor]
makeimagedevice
setdevice

%--- Some transformations
/showpage {} def
$scalefactor dup scale
$llx neg $lly neg translate

%--- The old EPS file
@epsfile

%---- Print bitmap on a file -------
/line BITIMAGE_WIDTH 8 idiv 1 add string def
/output BITIMAGE_FILE (w) file def
output (---------) writestring
output 10 write
0  1  BITIMAGE_HEIGHT 1 sub { %for
   output (%) writestring
   currentdevice exch
   line copyscanlines
   output exch writehexstring
   output 10 write
} for
output flushfile
quit
---EndGhostScriptProgram---

close GSFILE;
close STDIN;	# so that GhostScript can't read it.

@gsoutput = `gs -q -DNODISPLAY $gsfile`;   # run GhostScript
die "Can't run GhostScript" unless $? == 0;
unlink $gsfile;

@preview = grep(/^-----/ .. 1, @gsoutput);   # remove GhostScript garbage
shift(preview);
if ($#preview < 0) {
  print STDERR "GhostScript gives no output for the specified file\n";
  print STDERR @gsoutput;
  exit 1;
}

print shift(epsfile);
$_ = shift(epsfile);
while (/^%%/) {
  if (/^%%BoundingBox:/) {
    print "%%BoundingBox: $llx $lly $urx $ury\n" if !defined($boundingbox);
    $boundingbox = 1;
  } elsif (/^%%EndComments/) {
    last;
  } else {
    print;
  }
  $_ = shift(epsfile);
}
print "%%BoundingBox: $llx $lly $urx $ury\n" if !defined($boundingbox);
print "%%EndComments
%%BeginPreview: $width $height 1 $height\n";
print @preview;
print "%%EndPreview\n";

print grep(!(/^%%BeginPreview:/ .. /^%%EndPreview/) && !/^%%BoundingBox:/,
	   @epsfile);





###########################################################################
	# These next few lines are legal in both Perl and nroff.

.00;			# finish .ig
 
'di			\" finish diversion--previous line must be blank
.nr nl 0-1		\" fake up transition to first page again
.nr % 0			\" start at page 1
';<<'.ex'; #__END__ #### From here on it's a standard manual page #########
.TH EPS2EPSI 1 "May 1991"
.SH NAME
eps2epsi \- Filter for inclusion of a preview in an EPS file
.SH SYNOPSIS
.B eps2epsi
[
.B \-w
.I preview_width
] [
.I filename
]
.SH DESCRIPTION
.B Eps2epsi
puts a preview section in a PostScript file (preferably EPSF).
The preview produced
is in the encapsulated PostScript interchange format (EPSI)
suitable for import by FrameMaker and other document composing
systems.
.B Eps2epsi
reads the file specified (or standard input) and sends the new file
with the preview included to standard output.
.PP
.B Esp2epsi
uses
.B GhostScript
to render the preview bitmap, which means that
.B GhostScript
must be installed at your system before you can use
.B eps2epsi.
.SH OPTIONS
.TP 5
.BI \-w " n"
Set the width (in characters) of the preview section. This also specifies the
resolution of the preview as
.I n
times 4 horizontally.
.SH SEE ALSO
.BR perl (1),
.BR gs(1)
.SH AUTHOR
Gisle Aas, Norwegian Computing Center (NR), Oslo, Norway.
<Gisle.Aas@nr.no>
.ex

--
Gisle Aas               |  snail: Boks 114 Blindern, N-0314 Oslo, Norway
Norsk Regnesentral      |  X.400: G=Gisle;S=Aas;O=nr;P=uninett;C=no
voice: +47-2-453561     |  inet:  Gisle.Aas@nr.no

rhoward@msd.gatech.edu (Robert L. Howard) (06/01/91)

Beginner question alert!:

orthlieb@adobe.COM (Carl Orthlieb) writes:

>There is a PostScript program available on our mail server called 'epsfinfo.ps'
>that should do what you want.  You tack it onto the head of your PS file 
>and then send it down to the printer using SendPS or LaserTalk.  You will 
>then get back the bounding box and font usage info for your PS file.  If
>you then change the top of your file to read:
>	%!PS-Adobe-3.0 EPSF-3.0
>	%%BoundingBox: <llx> <lly> <urx> <ury>
>	%%DocumentFonts: <font1> <font2> <font3> ...

Would it be possible to get GhostScript to do this?  Has anyone done this?

Ideally, a perl (or whatever) program could invoke the epsinfo.ps program
to GhostScript (with your file of course) then take the answer back, stick
it onto the PS file and, viola, an EPS file on stdout...

...now if we could just get a PC TIFF type image header on top too...

Thanks,
Robert
--
| Robert L. Howard             |    Georgia Tech Research Institute     |
| rhoward@msd.gatech.edu       |    MATD Laboratory                     |
| (404) 528-7165               |    Atlanta, Georgia  30332             |
-------------------------------------------------------------------------
|     "Reality is showing us that perhaps we should do with nuclear     |
|      power the same thing Keloggs is advocating for Corn Flakes -     |
|      Discover it again for the first time." -- John De Armond         |

rst@lucifer.UUCP (Richard Thombs) (06/14/91)

Can anybody point me to a filter that converts PS into EPS? Or just tell me
how to do it? I hear it isn't very difficult, but I can't seem to figure it.

				Richard
-- 
Richard Thombs					      Lucas Powertrain Systems,
Mail:  rst@eg.lucasauto.co.uk			      Phoenix Way,
Phone: +44 285 657981 x233			      Cirencester, GL7 1QG,
Fax:   +44 285 658258 (G3)			      England.