Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is this a Postscript file?

1 view
Skip to first unread message

Ron Higgins

unread,
Feb 20, 1994, 6:14:58 PM2/20/94
to
I've got a couple of files that were meant for an Apple LaserWriter or
LaserWriter Plus printer.

I'm lookng to print them out onto a Postscript printer. The printer is
looking for a "%!" as the first 2 characters in the file, but my files are
not like this.

Q1: What type of file contains the %! as the first 2 characters?
Q2: What type of file is the following:

--
md begin
/tps 256 string def
/tct 0 def
/nsp{0 exch{32 eq{1}{0}ifelse add}forall}bdf
/sw{gsave 2000 dup moveto stringwidth pop grestore}bdf
/dlw{dup length 2 index mul 1 index nsp 4 index mul add 1 index sw add 5 -1 roll exch sub dup 0 ge}bdf
/dst{0 2 1 roll 0 4 1 roll 32 4 1 roll awidthshow}bdf
/tgt{1 index length dv 3 -1 roll add exch}bdf
/tabl{dup sw 1 index length dv 2 index add 4 index exch dv cvi /tct exch store 0 1 tct {tps exch 2 index 0 get put}for pop tps 0 tct getinterval}bdf
/rju{tabl dlw{currentpoint 3 1 roll add exch moveto}{tgt}ifelse dst}bdf
/fju{dlw{1 index nsp dv 4 -1 roll add 3 1 roll}{tgt}ifelse dst}bdf
/bf{mfont begin/FontType 3 def/FontMatrix [.6 0 0 1 0 0] def
/Encoding macvec def/BuildChar/bmbc load def
end mfont definefont pop}bdf
currentscreen /prc exch def
/ang exch def /frq exch def
--

I've only included the first couple of lines.

Q3: How do I convert this file to something that can be printed on a
postscript printer?

Thanks,
--
Ron |_ Lightning Systems | Lightning Systems
rhig...@carroll1.cc.edu |_ (414) 363-4282 200megs | P. O. Box 4
Apple // & Van Halen Forever! | 21.6k USR Dual Standard | Mukwonago, WI 53149
** Ask me about the new Turbo ASB for your Apple // Computer **

cla...@lsl.co.uk

unread,
Feb 21, 1994, 6:10:54 AM2/21/94
to

A1: PS files do traditionally start with %!, but the % introduces
a comment, so it shouldn't really be required. If it is required, then
just prepend whatever the printer appears to want.

A2: It certainly looks like PostScript, but only a fragment out of
something else. The bit quoted just is just defining stuff and would
not print anything. If executed as is, I would expect
'Error undefined: offending command is "md"' from the first line
unless it is executed is a context where "md" means something.

A3: Don't know. Could the file actually be the file format for some
software package, and hence only be 'pseudo' PostScript.

--
Clarke Brunt (CCB), Principal Software Engineer, Laser-Scan Ltd,
Science Park, Milton Rd, CAMBRIDGE, CB4 4FY, England.
Tel (+44) 223 420414; Fax 420044, Email CLA...@LSL.CO.UK (via BRITAIN.EU.NET)

Vidiot

unread,
Feb 22, 1994, 12:34:28 AM2/22/94
to
In article <2k8qti$3...@carroll1.cc.edu> rhig...@carroll1.cc.edu (Ron Higgins) writes:
<I've got a couple of files that were meant for an Apple LaserWriter or
<LaserWriter Plus printer.
<
<I'm lookng to print them out onto a Postscript printer. The printer is
<looking for a "%!" as the first 2 characters in the file, but my files are
<not like this.

First off the printer isn't looking for a %! at the beginning of the file.
Remember, a % is a comment character.

The %! is part of the magic-cookie used by print spoolers to let them know
that it is a PostScript file and not to convert the text to PostScript before
sending it off to the printer.

<Q1: What type of file contains the %! as the first 2 characters?

PostScript

<Q2: What type of file is the following:

PostScript. It just doesn't have the magic-cookie.

<md begin
</tps 256 string def
</tct 0 def
</nsp{0 exch{32 eq{1}{0}ifelse add}forall}bdf
</sw{gsave 2000 dup moveto stringwidth pop grestore}bdf
</dlw{dup length 2 index mul 1 index nsp 4 index mul add 1 index sw add 5 -1 roll exch sub dup 0 ge}bdf
</dst{0 2 1 roll 0 4 1 roll 32 4 1 roll awidthshow}bdf
</tgt{1 index length dv 3 -1 roll add exch}bdf
</tabl{dup sw 1 index length dv 2 index add 4 index exch dv cvi /tct exch store 0 1 tct {tps exch 2 index 0 get put}for pop tps 0 tct getinterval}bdf
</rju{tabl dlw{currentpoint 3 1 roll add exch moveto}{tgt}ifelse dst}bdf
</fju{dlw{1 index nsp dv 4 -1 roll add 3 1 roll}{tgt}ifelse dst}bdf
</bf{mfont begin/FontType 3 def/FontMatrix [.6 0 0 1 0 0] def
</Encoding macvec def/BuildChar/bmbc load def
<end mfont definefont pop}bdf
<currentscreen /prc exch def
</ang exch def /frq exch def
<

<Q3: How do I convert this file to something that can be printed on a
<postscript printer?

Add a %! as a separate first line.
--
harvard\ spool.cs.wisc.edu!astroatc!vidiot!brown
Vidiot ucbvax!uwvax!astroatc!vidiot!brown
rutgers/ INTERNET:vidiot!brown%astroa...@spool.cs.wisc.edu
br...@wi.extrel.com

Jean-Serge Gagnon

unread,
Feb 22, 1994, 1:00:21 PM2/22/94
to
Ron Higgins (rhig...@carroll1.cc.edu) wrote:
: I've got a couple of files that were meant for an Apple LaserWriter or
: LaserWriter Plus printer.

: I'm lookng to print them out onto a Postscript printer. The printer is
: looking for a "%!" as the first 2 characters in the file, but my files are
: not like this.

: Q1: What type of file contains the %! as the first 2 characters?

Postscript files that are syntactically (?sp) correct. The first couple
of years of PostScript printing did not take that into account, but today
all drivers include the %! PS-Adobe line as the first line in the file.

: Q2: What type of file is the following:

PostScript.

: --


: md begin
: /tps 256 string def
: /tct 0 def
: /nsp{0 exch{32 eq{1}{0}ifelse add}forall}bdf
: /sw{gsave 2000 dup moveto stringwidth pop grestore}bdf
: /dlw{dup length 2 index mul 1 index nsp 4 index mul add 1 index sw add 5 -1 roll exch sub dup 0 ge}bdf
: /dst{0 2 1 roll 0 4 1 roll 32 4 1 roll awidthshow}bdf
: /tgt{1 index length dv 3 -1 roll add exch}bdf
: /tabl{dup sw 1 index length dv 2 index add 4 index exch dv cvi /tct exch store 0 1 tct {tps exch 2 index 0 get put}for pop tps 0 tct getinterval}bdf
: /rju{tabl dlw{currentpoint 3 1 roll add exch moveto}{tgt}ifelse dst}bdf
: /fju{dlw{1 index nsp dv 4 -1 roll add 3 1 roll}{tgt}ifelse dst}bdf
: /bf{mfont begin/FontType 3 def/FontMatrix [.6 0 0 1 0 0] def
: /Encoding macvec def/BuildChar/bmbc load def
: end mfont definefont pop}bdf
: currentscreen /prc exch def
: /ang exch def /frq exch def
: --

: I've only included the first couple of lines.

: Q3: How do I convert this file to something that can be printed on a
: postscript printer?

Just add a line at the begining like this:

%! PS-Adobe-1.0

: Thanks,


: --
: Ron |_ Lightning Systems | Lightning Systems
: rhig...@carroll1.cc.edu |_ (414) 363-4282 200megs | P. O. Box 4
: Apple // & Van Halen Forever! | 21.6k USR Dual Standard | Mukwonago, WI 53149
: ** Ask me about the new Turbo ASB for your Apple // Computer **

--
---
Jean-Serge Gagnon e-mail:js...@acadvm1.uottawa.ca
Ottawa Univerity, Ontario voice:(613) 791-0785
Canada K1N 6N5 fax:(613) 564-7180
*** Get the PostScript Processing Speed Test (PPST) in /public ***
*** on gaaj.cosmos.uottawa.ca. It's a PostScript benchmark test. ***

Kevin Grover

unread,
Feb 22, 1994, 1:12:45 PM2/22/94
to
on 22 Feb 94 05:34:28 GMT, Vidiot (br...@vidiot.UUCP) wrote:

> <md begin
> </tps 256 string def
> </tct 0 def
> </nsp{0 exch{32 eq{1}{0}ifelse add}forall}bdf
> </sw{gsave 2000 dup moveto stringwidth pop grestore}bdf
> </dlw{dup length 2 index mul 1 index nsp 4 index mul add 1 index sw add 5 -1 roll exch sub dup 0 ge}bdf
> </dst{0 2 1 roll 0 4 1 roll 32 4 1 roll awidthshow}bdf
> </tgt{1 index length dv 3 -1 roll add exch}bdf
> </tabl{dup sw 1 index length dv 2 index add 4 index exch dv cvi /tct exch store 0 1 tct {tps exch 2 index 0 get put}for pop tps 0 tct getinterval}bdf
> </rju{tabl dlw{currentpoint 3 1 roll add exch moveto}{tgt}ifelse dst}bdf
> </fju{dlw{1 index nsp dv 4 -1 roll add 3 1 roll}{tgt}ifelse dst}bdf
> </bf{mfont begin/FontType 3 def/FontMatrix [.6 0 0 1 0 0] def
> </Encoding macvec def/BuildChar/bmbc load def
> <end mfont definefont pop}bdf
> <currentscreen /prc exch def
> </ang exch def /frq exch def
> <
> <Q3: How do I convert this file to something that can be printed on a
> <postscript printer?

> Add a %! as a separate first line.

It's postscript code, not a complete postscript program. It's like
saying

printf ("%d %s\n", line++, buf);

is a C program, just compile it and you're all set! I'm sure we all
see the problem with this. Well the above ps code fragement is that
same: it will only work in the context for which it was meant. (And I
don't just mean the code missing from the end, I'm talking more about
the setup missing from the beginning).

Sending it to a printer will mostly likely result in an error. It
looks like the prolog to some application -- i.e. its setting up
functions and variables that are used by the output of some program.

It's trying to open the "md" dictionary and store a bunch of
definitions there. However, "md" must be defined ("/md 40 dict def"
or such) before it will work.

--
- kev, gro...@isri.unlv.edu

Kevin Grover

unread,
Feb 22, 1994, 3:57:22 PM2/22/94
to
on Tue, 22 Feb 94 18:00:21 GMT, Jean-Serge Gagnon (j...@gaaj.uottawa.ca) wrote:

> Ron Higgins (rhig...@carroll1.cc.edu) wrote:
> : Q1: What type of file contains the %! as the first 2 characters?

> Postscript files that are syntactically (?sp) correct. The first couple

Syntax has nothing to do with it. % introduces a comment. This is
part of the syntax. However, the use the special comments by external
programs is a convention defined in the DSC (see below).

> of years of PostScript printing did not take that into account, but today
> all drivers include the %! PS-Adobe line as the first line in the file.

^^v^^^^^^^^
Clever users will realize there should
be no space here, but that's beside the point...

There seems to be some confusion on the use/reason for %!

Syntax has nothing to do with it. These comments are part of the DSC
(Document Structuring Conventions) -- KEY WORD: Conventions. It is a
CONVENTION that PostScript programs begin with a %! (so spooling
software can treat them different than other streams). To the
postscript interpreter the "%!blah..." is just another comment.
It is also a convention that PS files that conform to the DSC-#.# (where
#.# is the version of the DSC document) start with "%!PS-Adobe-#.#".
Furhtermore, it is a convention that EPS files (a subset of DSC) start
w/ "%!PS-Adobe-n.n EPSF-v.v" which tells other programs that the file
in question CLAIMS to adhere to the DSC convention n.n and EPSF
convention v.v.

Just adding "%!PS-Adobe-2.0 EPSF-2.0" to the beginning of ps code does
not magically make that file an EPS file. There are other parts of
the convention that must be followed.

> : Q2: What type of file is the following:

> PostScript.

Sort of. See my previous post on the subject: its postscript code,


not a complete postscript program.

> Just add a line at the begining like this:

> %! PS-Adobe-1.0
^^v^^^^^^^^^^^^
+--> again, clever users will realize there should be no space here


Not true. The file still will not print. It is NOT a COMPLETE
PostScript program. In fact, unlese code is inserted before it to
define the mb dictionary, it is not even semantically correct
PostScript code (it is however syntactically correct).

--
- kev, gro...@isri.unlv.edu

David A. Holzgang

unread,
Feb 23, 1994, 1:33:30 AM2/23/94
to
Higgins) wrote:

Well, I see you've got a lot of information on the net about this, but I
don't think anyone has covered the most important bit. The first line of
your program. "md begin", tells you that this is a file generated on a
Macintosh system, by the LaserWriter printer driver. "md" is the standard
Apple dictionary that is required to print any output of a Mac; it is
stored on the system as the file named "LaserPrep". On versions of the
Apple System software prior to 7.0, the driver required that the md
dictionary be loaded prior to printing any file. After System 7.0, Apple
changed the driver to download the dictionary with every file. What you
need to do is get a copy of the appropriate version of "md" and download it
to your printer prior to sending this file. It will probably print then.

As several others have noted, the use of the DSC comments is not necessary
to print any PS file. The interpreter discards all the comments, so that
the most likely problem that you will have is the lack of the LaserPrep
dictionary.

Good luck.

David Holzgang

Henry Churchyard

unread,
Feb 23, 1994, 10:08:22 AM2/23/94
to
In article <1994Feb22.2...@unlv.edu>,

Kevin Grover <gro...@wiggins.ISRI.UNLV.EDU> wrote:
>There seems to be some confusion on the use/reason for %!
>
>Syntax has nothing to do with it. These comments are part of the DSC
>(Document Structuring Conventions) -- KEY WORD: Conventions. It is a
>CONVENTION that PostScript programs begin with a %! (so spooling
>software can treat them different than other streams). To the
>postscript interpreter the "%!blah..." is just another comment.

There are printers that treat a job beginning with %! differently from
other jobs. In these circumstances, I would hardly call "%!" a
``comment''; I would say it is pretty much obligatory at this point...

--
p b tTd kqg '
scz S H ` h _ ___ _ ____ Henry
m n | | | | Churchyard
$ l | __| | | churchyh@ccwf.
r . . . . cc.utexas.edu
w y . .

J Greely

unread,
Feb 23, 1994, 11:58:23 AM2/23/94
to
In article <2kfrh6$b...@sneezy.cc.utexas.edu> chur...@sneezy.cc.utexas.edu

(Henry Churchyard) writes:
>There are printers that treat a job beginning with %! differently from
>other jobs.

These are printers that support multiple languages with automatic
switching between them. If you have such switching turned on, then
the "%!" cookie is usually required. Some printers are "bright"
enough to look further into the file.
--
J Greely (jgr...@synopsys.com)

Kevin Grover

unread,
Feb 23, 1994, 2:16:10 PM2/23/94
to
on 23 Feb 1994 09:08:22 -0600, Henry Churchyard (chur...@sneezy.cc.utexas.edu) wrote:
> In article <1994Feb22.2...@unlv.edu>,
> Kevin Grover <gro...@wiggins.ISRI.UNLV.EDU> wrote:
> >There seems to be some confusion on the use/reason for %!
> >
> >Syntax has nothing to do with it. These comments are part of the DSC
> >(Document Structuring Conventions) -- KEY WORD: Conventions. It is a
> >CONVENTION that PostScript programs begin with a %! (so spooling
> >software can treat them different than other streams). To the
> >postscript interpreter the "%!blah..." is just another comment.

> There are printers that treat a job beginning with %! differently from
> other jobs. In these circumstances, I would hardly call "%!" a
> ``comment''; I would say it is pretty much obligatory at this point...


Then the printer has software ACTING BEFORE THE POSTSCRIPT processor,
thats taking some of the duties of spooling software. To ANY and
EVERY postscript processor, % introduces a comment (when not inside of
strings, etc..) and is summarily discarded.

If this is not the case, then we are not taking about a real
postscript processor. or, as in the above case, there are other
programs running that try to figure out what type of input the file is
and deal with it appropriatly.

--
- kev, gro...@isri.unlv.edu

Henry Churchyard

unread,
Feb 24, 1994, 8:47:59 PM2/24/94
to
In article <1994Feb23....@unlv.edu>,

Kevin Grover <gro...@wiggins.ISRI.UNLV.EDU> wrote:
>on 23 Feb 1994 09:08:22 -0600, Henry Churchyard (chur...@sneezy.cc.utexas.edu) wrote:
>> In article <1994Feb22.2...@unlv.edu>,
>> Kevin Grover <gro...@wiggins.ISRI.UNLV.EDU> wrote:
>> > To the
>> >postscript interpreter the "%!blah..." is just another comment.
>> There are printers that treat a job beginning with %! differently from
>> other jobs.
>Then the printer has software ACTING BEFORE THE POSTSCRIPT processor,

This is a theological debate about whether the firmware in a
Postscript printer is part of a postscript processor. As far as I'm
concerned, if you have to send it to the printer in order for your
file to print correctly, then it's not a comment.

--
--Henry Churchyard chur...@ccwf.cc.utexas.edu


Ron Higgins

unread,
Feb 26, 1994, 11:27:33 AM2/26/94
to
Once again, many thanks go out to those who reponded to my plea for help in
determining what type of file I was dealing with.

It appears that I had two problems.

1) The print spooler on the machine that the LaserWriter IIg is connected
to needs to see a '%!' as the first two characters in the file, otherwise
it will convert the file into postscript. This is not what I had wanted, I
needed the spooler to pass the file directly to the printer as postscript.

Inserting the '%!' helped the file get past the print spooler.

2) I was told by numerous people that I needed to 'prepend' the 'laserprep'
file to my file in order for the postscript printer to corectly interpret
the commands being sent to it.

After looking again at the program that generated the file in question, I
found a box that I could check to have it send the 'laserprep' info. This
made the file grow by an additional 30k!

I haven't tried sending the file to the printer again, but I feel much more
confident now thanks to everyones help.

( Don't you hate those guys without a clue? :-) )

Anthony Datri

unread,
Feb 26, 1994, 6:44:58 PM2/26/94
to

>A1: PS files do traditionally start with %!, but the % introduces
>a comment, so it shouldn't really be required.

Am I the only one to consult the documentation? The red book (1rst ed)
sez on page 281 "The very first line of every PostScript program (whether it
is conforming or nonconforming) should be a comment that begin with the
characters '%!'."

>If it is required, then
>just prepend whatever the printer appears to want.

I evaluated a NewGen printer that would only recognize a job as PostScript
if the first line consisted of magic followed by a CRLF. Unix-style files
with LF-terminated lines were interpreted as text.

--

>--=8======-================================================================--
ILTFBMWHBSD

0 new messages