[comp.sys.mac] PostScript, LaserWriter, Unix Connectivity

zimm@Portia.Stanford.EDU (Dylan Yolles) (10/22/88)

I'm trying to do something which, in theory, should be relatively easy,
but which in practice seems quite difficult: create PostScript files
on my Macintosh (from Macintosh applications, such as Word), upload them
to a Unix system, and finally dump those files to the LaserWriter +'s and
NT's connected to the mainframe.

The saga of my efforts to accomplish this are too long and complicated to
repeat here. Suffice it to say, by trial and error, I've gotten things sort
of working with some fonts on some printers some of the time with a very
specific driver. But I'm having a hard time getting files with fonts other
than Times and Helvetica in them to print out (although the fonts
are ROM resident).

I've really spent many hours trying to figure this out, and am about ready
to give up--if you know what to do, I'd be eternally grateful for your help!
So, if you have any info which might help, please let me know. Also,
if you're trying to do what I'm trying to do (and similarly failing), send
some mail, and I'll let you know what the results of my investigation are.

Your best bet is to respond at 

zimm%portia@forsythe.stanford.edu

I don't get on the net much, so I probably won't see any messages posted
here.

Thanks for any help you might offer--Dylan Yolles

edmoy@violet.berkeley.edu (10/23/88)

In article <@psych.stanford.edu> zimm%portia@forsythe.stanford.edu writes:
>I'm trying to do something which, in theory, should be relatively easy,
>but which in practice seems quite difficult: create PostScript files
>on my Macintosh (from Macintosh applications, such as Word), upload them
>to a Unix system, and finally dump those files to the LaserWriter +'s and
>NT's connected to the mainframe.
>
> . . .
>
>Your best bet is to respond at 
>
>zimm%portia@forsythe.stanford.edu
>
>I don't get on the net much, so I probably won't see any messages posted
>here.
>
>Thanks for any help you might offer--Dylan Yolles

(I'm posting this to the net and mailing Dylan a copy since the answer is of
general interest.)

The inexpensive way to do this is to get a copy of my macps program that I
rosted to comp.sources.mac sometime ago (though I haven't seen it yet).  I
do know it is available by anonymous ftp to sumex-aim.stanford.edu (10.0.0.56 or
36.45.0.87) in the <info-mac> directory.  Following is the introductory
message from my posting:

[Macps is a Unix program that takes a PostScript file created on a Macintosh
[by typing Command-F to the LaserWriter dialog box and includes an appropriately
[modified LaserPrep file so that the result can be sent to a PostScript printer
[from Unix.  Unlike most of the other versions of this program, this one
[includes a second program, prepfix, that converts LaserPrep files to a form
[compatible with Unix (and can even be electronically mailed).

The other way to do this is more expensive in that it requires an AppleTalk
to Ethernet gateway (like a Kinetic's FastPath or a GatorBox).  Then you
can run either the Columbia AppleTalk Package (CAP) on the Unix side
(available by anonymous ftp from cunixc.columbia.edu 128.59.40.130 or
sumex-aim) and the KIP code in the FastPath (available from sumex-aim again),
or you can spend more money and buy TOPS.  (By the way, besides printer
access, these systems provide file serving as well, with CAP using
AppleShare, which is now include in system 6.0.2, or by using TOPS
file serving.)

Edward Moy				Principal Programmer - Macintosh & Unix
Workstation Support Services		Workstation Software Support Group
University of California
Berkeley, CA  94720

edmoy@violet.Berkeley.EDU
ucbvax!violet!edmoy

knapp@cs.utexas.edu (Edgar Knapp) (10/23/88)

I have had problems, too, getting laserwriter output on a Unix Vax
from postscript created on my mac. I am aware of the existence of
maclaser, which is supposed to accomplish this. But it just doesn't
work. Is there a solution?

Thanks

Edgar

(knapp@cs.utexas.edu)

olson@batcomputer.tn.cornell.edu (olson) (10/24/88)

In article <@psych.stanford.edu> zimm%portia@forsythe.stanford.edu writes:
>I'm trying to do something which, in theory, should be relatively easy,
>but which in practice seems quite difficult: create PostScript files
>on my Macintosh (from Macintosh applications, such as Word), upload them
>to a Unix system, and finally dump those files to the LaserWriter +'s and
>NT's connected to the mainframe.
>

Well I have been doing this sort of thing for quite some time now
with some code written by Ron Hitchens  and Brian Powell
Below I have included two readme files that came with their stuff.
This should explain what is involved.  Save it so you can share the info with 
others.  I suggest you try to contact them for the software because you'll
need the latest version of the laserprep (or the latest you are using)
Also, since I've heard that some mac programs use there own laser prep
(I can't remember which ones ...) you may need appropriately hacked 
laserpreps for those programs.

If you can't get the software from powell or hitchens send me a note
and I'll send you what I have.

(Note I have got this stuff to work with an apple laser writer hung off
 both a vax750 (BSDUNIX and hung of a Sun3/280 running OS3.5)

Todd Olson
olson@helios.tn.cornell.edu
------------------------------------------------------------


   Paintps depends on the "Mac environment" being present in the LaserWriter
at the time its Postscript output is processed.  This environment is setup
by the laser-prep prolog file which is prepended by the Mac print drivers
when a Mac prints directly to a LaserWriter.  Since paintps basically
mimics what MacPaint does when it prints a file on a LW, something needs
to be done to provide the Mac environment in the LW with the Unix system.

   The same applies to any "Mac PostScript" file produced on a Mac and
captured with the Command-F sequence and then uploaded to a Unix machine.
The remaining discussion concerns printing Mac files to a LaserWriter
being driven by a Unix (4.2 or 4.3 BSD) spooler and which is primarily
used for general text processing, not for Mac output.  The output of
paintps is considered a "Mac file", even though it's produced on a
Unix system, and is included in the general discussion below.

   The first step is to get the laser-prep prolog file, so that it can be
sent to the LW via the spooler.  The laser-prep file must be modified
for use with the spooler.  There are two reasons why.
	1) The standard laser-prep installs itself permanently, on the
	   assumption that the LW is living in a Mac-only universe.  The
	   amount of memory it consumes is substantial and we aren't
	   willing to give it away to accomodate the occasional Mac
	   job sent via the Unix spooler.  Removing the few lines
	   at the beginning which escape from the server loop is
	   sufficient to prevent permanent residency.
	2) The encrypted smoothing function in the laser-prep is fed
	   as stdin to an eexec command which will read until eof.  Since
	   what we're trying to accomplish is to have the laser-prep only
	   live for the duration of a single job, this presents a problem.
	   Luckily the eexec command will also accept a string argument
	   on the stack, so by placing hex quotes (<>) around the smoothing
	   code and calling eexec after it has been placed on the stack,
	   we get the same effect plus the ability to continue sending
	   PostScript code afterwards.  Hence, we can simply concatenate
	   the modified laser-prep and the Mac PostScript file and send
	   it to the printer, the Mac environment will be there for the
	   job and will be flushed afterwards.
   This will also allow us to support more than one version of the LaserWriter
driver in the future (which we intend to do.)  Since the laser-prep won't be
in the LW RAM, we can prepend any laser-prep without causing a conflict.

   Now, there are a couple of ways to handle a Mac PostScript job via
the Unix spooler.
	1) On the front end of the spooler thru lpr, such as:
		paintps foo.mp > foo.ps
		cat /usr/local/lib/laser-prep.pro foo.ps | lpr -Plw
	   This is the most generic and doesn't require anything special
	   be done on the unix system.  The drawbacks are that a current
	   copy of the laser-prep must be present on every system that might
	   spool a job, that users know where it is, and that they know
	   the proper incantations.  A shell script could be written to
	   hide the above commands, but that still requires multiple
	   copies of the laser-prep file.
	2) In the back end of the spooler, by having a filter automatically
	   prepend the laser-prep to all Mac PostScript jobs.  This is 
	   the most elegant way to handle it, since only one copy of the
	   laser-prep need exist on the system where the printer is, and
	   the details of handling Mac specific files are hidden from
	   the user.  This method requires selecting a "file type" for
	   spooling Mac jobs and specifying the proper handlers on the
	   system where the printer is.  At UT we chose the "Fortran"
	   file type, since it was unused.  Others could be used but
	   there aren't many candidates, especially if you already
	   support ditroff and/or TeX.  We handle spooling of Mac files
	   with a shell script which simply calls lpr and adds the -f
	   file type flag.

   The discussion below assumes the reader is familiar with how the 
Berkeley spooler works and knows how to setup filters.  The person
who does this must have super-user access anyway.  Once again there
are two ways to go about setting up your spooler to handle Mac PostScript
files:
	1) If you're using the standard Transcript setup, use the psmac
	   shell script included.  Put it in /usr/local/lib, or where
	   you keep the rest of your filters, and put its name in the
	   printcap slot for whichever file type you use (the rf field
	   is for the Fortran type, go figure).
	2) If you're using an Imagen-style shell script which is called
	   by several different names, use our psfilter (included) as
	   a guide and include a case for handling Mac files as shown.
	   This approach is kind of odd, and can lead to various problems,
	   but allows more flexibility and enables you to do things
	   like complex pipelines and problem notification.  Psfilter
	   is what we use at UT, you may or may not find it useful.
	   In any case you can ignore the local hacks for dealing
	   with LaserWriters on Bridges (unless you have some, I might
	   be able to help).

   The program macfilter, named in both psmac and psfilter, does nothing
more than convert any non-printable characters in the data stream to 
the octal equivalent.  Apple broke the rules and used non-printable
characters (specifically non-ascii > 128) for certain symbols.  These
don't survice the unix device driver (they lose the high bit) and raw
mode is not possible because the LW needs to use flow control.

   Here is the /etc/printcap we use here at UT:
#
#
# Apple LaserWriter
# sb MUST be specified, psof depends on it.  psof prints job header page.
# rw must be specified, printer talks back to psif

lw-generic|Apple Laserwriter:\
	:rw:br#9600:ff=:tr=^D:sc:sb:\
	:of=/usr/local/lib/psof:\
	:df=/usr/local/lib/psdvi:\
	:nf=/usr/local/lib/psditroff:\
	:tf=/usr/local/lib/pscat:\
	:if=/usr/local/lib/psasc:\
	:cf=/usr/local/lib/psbad:\
	:gf=/usr/local/lib/psbad:\
	:vf=/usr/local/lib/psbad:\
	:rf=/usr/local/lib/psmac:

Lazarus|lw1|lw|lazarus|LW connected to im4u:\
	:lp=/dev/lw:sd=/usr/spool/lw1:\
	:xs#040400:fc#070:fs#00302:\
	:lf=/usr/adm/log-lw1:\
	:af=/usr/adm/lw.acct/lw1:\
	:tc=lw-generic:
-------------------
Ron Hitchens	University of Texas at Austin, Computer Science
hitchens@uo.cs.utexas.edu
hitchens@sally.UUCP
------------------------------------------------------------
------------------------------------------------------------
------------------------------------------------------------

     This shell archive contains a program called paintps which will convert
a MacPaint file (uploaded from a Mac) to PostScript for printing on a
LaserWriter.  It reads a plain MacPaint document as input and produces 
postscript output in the same style as that produced by the 1.1 version
of the Mac LaserWriter driver.  Paintps runs on unix and will automatically
spool its output for printing if no output redirection has been done.
The advantage of paintps is that MacPaint pictures are usually less than
25K, while the resulting PostScript often exceeds 100K.  This obviously
reduces the file transfer time.

     Also included is the version 1.1 laser-prep file, which is needed
by paintps, and a shell script called maclaser, which is called by paintps
to spool its output.  Maclaser is simply a front end to lpr, and depends
on the spooler setup described in the file README.SPOOL.  
     
     This code has been used with 4.2 and 4.3BSD; vaxen, Sun and Sequent
hardware.  We use the TranScript package from Adobe to drive the LaserWriter.
If you're using some other set of PostScript drivers, the spooler hacks
are basically the same, since there are no changes to the drivers themselves.

     Paintps is distantly related to a program called paintimp, originally
written by Dave Johnson at Brown University.  It converted MacPaint pictures
to Impress for printing on Imagens.  Ron Hitchens at the University of
Texas hacked on it a bit and added some features.  When we got a LW,
Brian Powell at UT was inspired to do something similar for PostScript.
The resulting paintps is very different from paintimp, but paintimp did
provide the structure and a few subroutines.  Maclaser and the spooler hacks
were conceived by Ron Hitchens' twisted mind.

     There are several different critters in this distribution.  They 
probably won't all want to live in the same place.  A makefile is included
for paintps, mainly because it was already there.  Use your local customs
for determining where things should go.

     NOTE:  Maclaser can print PostScript generated by any Macintosh program,
not just MacPaint.  (See the man page for maclaser for details.)  For now, you
must use version 1.1 of the LaserWriter driver to generate the PostScript on
the Macintosh.
     You do not have to have the LaserWriter printer driver on the Macintosh
to use paintps.
     When Apple settles down on their Printer Drivers, I will modify this
code to support the latest 3.* LaserWriter driver.  The latest driver I have
seen is version 3.1, and I don't think it will be hard to modify paintps to
produce that driver's new format.
     And by the way, the "Chooser" desk accessory won't install the version 1.1
LaserWriter driver.  To use LaserWriter 1.1 with the new systems, simply install
and use "Choose Printer" (from Finder 4.1 days).  I have noticed no problems
using the old driver with the new ROMS or new system.

-------------------------
Brian Powell	brian@sally.utexas.edu
Ron Hitchens	hitchens@sally.utexas.edu