Subject: Re: printing to Xerox 230 ST
To: Wolfgang Rupprecht <wolfgang@wsrcc.com>
From: Roger Brooks <R.S.Brooks@liverpool.ac.uk>
List: netbsd-help
Date: 06/18/1999 23:08:11
On 17 Jun 1999, Wolfgang Rupprecht wrote:

>
>It should be ok to add ^M to the end of lines for ascii ps files.  I'm
>told that there are programs that can send raw binary picture data to
>a postscript interpreter.  I'm sure that adding a ^M after every ^J
>would make a royal mess of things there.  Luckily I've never seen a
>program output a ps file with embedded binary data.  All the output
>I've seen has constructed picture data from either pure hex data or
>some other printable representation.

If the PS file is DSC complient, the binary sections should be delimited
with:

%%BeginBinary: <count>

%%EndBinary

or

%%BeginData: <count> binary bytes

%%EndData

(the first form is deprecated), and you can then pass the binary data
transparently.  Unfortunately, the Microslop Windoze drivers (while
being fairly DSC-complient otherwise), don't delimit binary data.  I've
had to write print filters to deal with this crap, and it's a real pain
in the arse, because the file starts out being record-oriented (and
usually ends up likewise), but you can get chunks of binary data at any
point.  in the end I had to write a modified fgets() which returns a
byte-count so the buffer doesn't get truncated at the first NULL.

And yes, if you simply add CR before or after every LF and there's any
binary data it will be totally FUBAR.

>I'm not exactly sure how a ps with binary is constructed so that among
>other things the terminating ^D still terminates the file but embedded
>^D's don't.  

The ^D terminator isn't supposed to be in the file.  That's what the
Adobe documentation says.  Any ^D in a stored PS file shoud be interpreted
as binary data, not a terminator.  But when the print spooler sends the
data to the printer, it encodes those control chars which have special
meaning on the comms link (^A, ^C, ^D, ^T, ^S, ^Q and a couple of others)
thus:

	^D  ->  ^AD

and a ^D sent *over the comms link* still means EOF. The print filter is
supposed to add this itself (when it does a read and gets EOF).  If you
need to explicitly put an EOF in the file, you're supposed to use

%%EOF

which should make the print filter send a ^D.



Roger

------------------------------------------------------------------------------
Roger Brooks (Systems Programmer),          |  Email: R.S.Brooks@liv.ac.uk
Computing Services Dept,                    |  Tel:   +44 151 794 4441
The University of Liverpool,                |  Fax:   +44 151 794 4442
PO Box 147, Liverpool L69 3BX, UK           | 
------------------------------------------------------------------------------