[comp.lang.postscript] Proper postscript file?

haskins@s.cs.uiuc.edu (12/15/89)

This is a sample of the beginning and end of a postscript file that is
produced by Borland's Sprint.  In the third line, you see a ^D (which
I have changed to \^\D).  Is that normal?  There is a program on the
campus that will read a postscript file and squirt it to a postscript
printer, and when it hits that ^D, it stops there and thinks it's done.
I end up having to manually strip it out right before I send it along.
So is it something that should be complained about, or ....?  There's
also a ^D at the end, too.

Thanks much.

L. Haskins -- haskins@cs.uiuc.edu

-cut here -
%!PS-Adobe-2.0
%%Creator: Sprint V1.00
^D
/mainvm save def
(\032) cvn {} def
%statusdict begin /waittimeout 0 def end % infinite time-out usually not needed
/ff {/vpitch exch def findfont vpitch scalefont setfont
	/hpitch ( ) stringwidth pop def
	/hpextra 0.0 def
	} bind def                                 % 'ff' is find-font
/x {currentpoint exch pop moveto} bind def      % 'x' is absolute x positioning
/n {currentpoint exch pop 0.0 exch vpitch sub moveto} bind def % 'n' is newline
/v {/vpitch exch def} bind def                  % 'v' is vertical line height
......[many lines removed]........
1800 x /Optima 300 ff 83 h (Optima)p n
n
1800 x /Palatino-Roman 300 ff 75 h (P)p 141 h ( latino)p 
1972 x (a)p n
n
1800 h ( )p /Symbol 300 ff 75 h (Symbol)p n
n
1800 x /Times-Roman 300 ff (Times)p n
n
1800 x /Helvetica 300 ff 83 h 0.5 setgray (gray)p n
savevm restore showpage

%%Trailer
mainvm restore
^D

henry%angel@Sun.COM (Henry McGilton -- Software Products) (12/15/89)

In article <208400001@s.cs.uiuc.edu>, haskins@s.cs.uiuc.edu writes:

    *  This is a sample of the beginning and end of a
    *  postscript file that is produced by Borland's Sprint.
    *  In the third line, you see a ^D (which I have changed
    *  to \^\D).  Is that normal?  There is a program on the
    *  campus that will read a postscript file and squirt it
    *  to a postscript printer, and when it hits that ^D, it
    *  stops there and thinks it's done.

Yes.  That's because the printer communications protocol interprets
control-D as end of job.
    
    *  I end up having to manually strip it out right before I
    *  send it along.  So is it something that should be
    *  complained about, or ....?  There's also a ^D at the end, too.

Complain Long and Loud.  Control-D is NOT a part of the
PostScript Language.  Control-D is a part of the printer
communications protocol.  These extraneous contrlol-D
characters in PostScript files create unending headaches
for applications importing so called Encapsulated
PostScript from other applications.

	     <  PostScript Program Deleted  >

It's not in the application's domain to decide that
communication protocol codes should or should not be added
to PostScript programs.  That's the responsibility of
whatever printer control program is communicating with the
printer.  Applications should emit correctly conforming
PostScript, and should not make unwarranted assumptions as
to the ultimate destination of the PostScript.

Adobe are right -- applications that append control-D
characters to PostScript programs are wrong.


	................... Henry

+------------------+------------------------+---------------------------+
| Henry McGilton   | I saw the future,      | arpa: hmcgilton@sun.com   |
| Sun Microsystems | and it didn't work.    | uucp: ...!sun!angel!henry |
| Mt. View, CA     |                        |                           |
+------------------+------------------------+---------------------------+

mcdonald@aries.scs.uiuc.edu (Doug McDonald) (12/15/89)

Concerning control-D's at the end of Postscript output from programs:

There is a big problem here. One SHOULD be able to send the output of
a program to the printer. And get it to work. In other words,
on MS-DOS you should simply be able to say 

print file.psc

and get your output. This is because Postscript is plain ASCII - 
otherwise you would need to use binary mode.

IF that doesn't work, I would assume that there is something 
wrong with the printer. It is sort of silly to have to kludge up
some mechanism to send a control-D to a printer to get it to work.
Requiring a "printer control program", whatever that may be, 
is a kludge.

Doug McDonald

rokicki@polya.Stanford.EDU (Tomas G. Rokicki) (12/15/89)

mcdonald@aries.scs.uiuc.edu (Doug McDonald) writes:
> Concerning control-D's at the end of Postscript output from programs:

This has been discussed to death already.

> There is a big problem here. One SHOULD be able to send the output of
> a program to the printer. And get it to work. In other words,
> on MS-DOS you should simply be able to say 

> print file.psc

> and get your output. This is because Postscript is plain ASCII - 
> otherwise you would need to use binary mode.

This will indeed work---provided you insert a pause between jobs of
a minute or more.  (Most PostScript printers `infer' a ^D if they
don't get data for some settable period---usually a minute or so.)

The ^D just indicates that the job is done, and the printer can
reclaim any memory used by that job.  It's a feature, not a bug.

> IF that doesn't work, I would assume that there is something 
> wrong with the printer. It is sort of silly to have to kludge up
> some mechanism to send a control-D to a printer to get it to work.
> Requiring a "printer control program", whatever that may be, 
> is a kludge.

It's not a kludge.  It's a solution to a very real problem.  There
is a certain `state' that should be in effect at the beginning of
each job.  Without something to separate jobs, there is no way
to know when this state should be established.  Similarly, there
is no way to know how much to flush should an error occur.
(Hence the problem with some other printers---if you abort, for
instance, some graphic dump, you have to power cycle the printer
to get it to talk to you again.  Or if the printer runs out of
memory, it either locks until someone power cycles it, or it spews
out random garbage until things start working again.  Certainly
you've accidentally tried to `print' a binary program before?)

A compromise that is used by many applications is to simply note
whether the output is being directed to a file (in which case no
^D is written) or to a device (in which case, a direct connection
to the printer is assumed and a ^D is written at the end of the
job.)

Note that on your hypothetical MS-DOS system (people don't really
use them, do they? *shudder*) `print' doesn't work anyway for text
files---perhaps the most commonly printed thing---so a `special
program' is needed anyway.

> Doug McDonald

-tom

woody@rpp386.cactus.org (Woodrow Baker) (12/15/89)

yes they do. MSDOS is *MUCH* friendlier than Unix.  I am not looking for
flames, so DONT!

Thanks

Cheers, Woody

haskins@s.cs.uiuc.edu (12/17/89)

Original poster here...

I received a note from a fellow SPRINT user (there are so few of us :-(  )
that said my situation could be remedied by modifying the header file a
tad.  Well, that'll get rid of the leading ^D.  Now if I could just get rid
of the printer control program!

Thanks to all that helped me out!


L. Haskins -- haskins@cs.uiuc.edu

haskins@s.cs.uiuc.edu (12/19/89)

Original poster (again) here....

In looking a little harder at some of the responses to the basenote,
it may have been assumed that I was using some DOS feature to get my
postscript file from the PC to the Apple laserprinter.  Alas, 'twas
not.  The (only!) site at my school that has DOS -> postscript laser
printing has a friendly little program that will print your <insert
officially-school-supported-word-processor-program here> file for you,
and, oh yeah, they'll send a postscript file directly, if you insist.
Unless the program gets feedback somehow from the printer, it probably
interprets ^Ds as a flag that the file's done.  How convenient.

Well, I'm glad we're almost out of the '80s.

L. Haskins -- haskins@cs.uiuc.edu