[comp.sys.mac.misc] HOW TO: Generating Postscript

ksbolduan@amherst.bitnet (09/20/90)

Well, since I can't distribute a hacked version of the LaserWriter driver for
those who want to be able to generate Postscript files quickly and easily,
here, at least, are the instructions. I picked this up off of the
sumex-archives, but figured that it warrented full reproduction here. Good luck
for anyone producing Postscript files.

Kevin Bolduan
KSBOLDUAN@AMHERST

-= -= -= -= -= -= -= -= -= -= -= -= -= -= =- =- =- =- =- =- =- =- =- =- =- =-

Date: Mon, 17 Sep 90 02:03:20 -0500
From: Don Gillies <gillies@cs.uiuc.edu>
Subject: <info-mac>tips>generating-postscript.txt

Not a good night; here's the last try.  This is THE FINAL VERSION.

Here is a revised version of the entire file "generating-postscript.txt"
for the info-mac archives.  This file is a condensation of the earlier
file, and contains new procedures and new pointers to files all over
the archives, having to do with postscript generation and printing.
Please let this file replace the old "generating-postscript.txt" file.
Thank you very much.

Don W. Gillies, Dept. of Computer Science, University of Illinois
1304 W. Springfield, Urbana, Ill 61801      
ARPA: gillies@cs.uiuc.edu   UUCP: {uunet,harvard}!uiucdcs!gillies

---------------------------- cut here -----------------------------

The following information is condensed from earlier messages in
"generating-postscript.txt" and other sources.  Here are some of the
contributors:
	gillies@cs.uiuc.edu			Ray_Davison@cc.sfu.ca 
	dmg@mitre.mitre.org			Les_Ferch@mtsg.ubc.ca
	jhl%naif.span@vlsi.jpl.nasa.gov (Jay Lieske)
	Russ Evans <E_GS18%vaxa.nerc-murchison.ac.uk@nsfnet-relay.ac.uk>
	The Blue Adept <KSBOLDUAN%AMHERST.BITNET@cunyvm.cuny.edu>

-----------------  How to generate a postscript file ---------------

(1) THE ONETIME POSTSCRIPT GENERATOR

This is a fast way for people who generate postscript twice a year,
and can't modify the system software on their machine (e.g. lab machine)

Select "Chooser" from the Apple menu, and then tell it you have
appletalk hooked up (lie).  If you really are using appletalk, then
you will have problems if there is no laserwriter on the network.  In
this case, perhaps you will be forced to disconnect appletalk.

Select the LaserWriter (not the LaserWriter SC driver.)  Turn
Background Printing off if you are using MultiFinder.  Selecting the
LaseWriter This will cause small formatting changes in most word
processors, since the laserwriter has larger characters than the
Imagewriter or other printers.  They can easily ruin a well-formatted
resume.  Go to your word processor and correct the lines that have now
changed.  It is a good idea to leave the laserwriter selected all the
time, if possible, so your documents are created with these changes
already in place.

Get ready to print the document in the normal fashion.  When you see
the LaserWriter dialog, click on OK and immediately type and hold
either the "k" key or the "f" key. You must depress the key immediately
within the first 1-2 seconds AFTER the dialog disappears.  Do not use
command-F or command-K, as there might be problems in depressing the
key too soon after clicking OK on the dialog.  

If you get a message "looking for laserwriter", then you probably hit
the key too late.  In that case, try again; when the print dialog
comes up instead of clicking on the OK button, HOLD THE MOUSE DOWN
without releasing it.  Then at your leisure press the "f" or "k" key
and then FINALLY release the mouse.

You should see a file called Postscript0 appear in the current folder.
The next time you do it, if Postscript0 already exists, Postscript1
will be generated, etc.  When Postscript9 is generated, no further
files will be generated.

The difference between these commands is that "k" prepends the
contents of Laser Prep to your Postscript output; "f" does not.  

(2) THE WEEKEND POSTSCRIPT GENERATOR

This is for people who want to occasionally generate postscript, but
also want to occasionally print directly to an attached serial or
appletalk laserwriter.

We suggest you add "Disk File" box in the laserwriter dialogue.  It
turns out that every laserwriter icon since version 5.2 (v5.2) can
have this option [Yes, Dorothy, you can go back to Kansas].  One way
to accomplish this is to employ the MyPageSetup utility, available as:
	[sumex-aim.stanford.edu]<info-mac>util>mypagesetup13.hqx

Another way to accomplish this is via ResEdit:

    (a) Make a copy of the Laserwriter icon to fiddle with.

    (b) Using the latest version of ResEdit (v1.2 or later), open the copy
	and then open DITL #-8191.  Choose "Select Item Number" from the DITL
	menu, and enter number 22.  Close the Window and then choose "Open As
	Dialogue Item" from the File menu.  This should open a window
	describing a "Disk File" item, which has a bounding box of
	((0,0)(0,0)).  This box is all zeroes, which is why the "Disk File"
	checkbox is invisible.  Change it to something useful
	((49,314)(65,395)) and close the window.  The word "Disk File" should
	now appear in the dialogue box.  Drag it elsewhere to change
	the positioning.  Close ResEdit and save your changes.

Now, every time you print, you may select the checkbox in order to
generate a "Postscript0", "Postscript1", ... etc. file.  

(3) THE SERVICE-BUREAU USER

These people want to name the postscript file something similar to the
name of the original document; this helps them keep track of their
archived postscript files.

The following INIT adds a "Disk File" checkbox to the laserwriter
dialogue, and prompts the user to name the Postscript file directly,
when "Disk File" is turned on:
	[sumex-aim.stanford.edu]<info-mac>util>laser-fix-10.hqx

(4) THE IMPATIENT USER WITH NO LASERWRITER AT ALL

This is for people who never have access to a laserwriter from their
macintosh.  These people want a file named "Postscript0" on their disk
as fast as possible.  This file will be immediately uploaded & deleted
from the macintosh, so the name "Postscript0" perfectly acceptable.

It turns out the "Disk File" box will not stay ticked (so far as we
know), so we suggest you patch the laserwriter driver to ALWAYS
generate a postscript file.  Begin by making a spare copy of your
"Laserwriter" icon (because you can easily damage it permanently).
Then use ResEdit to make the following patches to the copy (note: you
will be editing a string of hex digits; do not change the length of
the string).

	     Resource PDEF number 125
	           location       From       To
Laserwriter     v5.2   v6.0
	         B96    C78       '57C0'    '51C0'
	         B9A    C7C       '56C0'    '50C0'
	         BA2    C84       '57C0'    '50C0'   ('51C0' for Laser Prep)
	         BAA    C8C       '57C1'    '51C1'   ('50C1' for Laser Prep)
	         BB8    C9A       '57C1'    '50C1'

Close ResEdit and save your changes.  Now, when printing, if you
select "OK" in the dialogue, a Postscript file will always be generated.

(5) THE USER WITH A DEDICATED COMPUTER + PRINTER ON HIS/HER SERIAL PORT.

This is for someone who has a workstation or mainframe listening to
the macintosh serial port.  This workstation or mainframe is connected
to a postscript printer.  The workstation or mainframe is running a
program ready to accept a postscript file and spool it to the printer.

..Awhile ago someone had a request for information on connecting a
LaserWriter to the serial port through a switch box. I had a similar
need. I have a Mac and a Unix box and wanted to use the printer on the
Unix box from the Mac.  I didn't want to spend the money for a
Kinetics box for just one Mac so I went the route of using command-F
to create a file, moving the file to Unix and using macps to print the
file. This was rather tedious.
 
I modified the LaserWriter driver as outlined below. The changes I made
were specifically designed to print over a serial connection from the Mac
to the Unix box, but may be useful to print to a serial connected LaserWriter.
 
Changes to the LaserWriter driver (versions 5.2 and 6.0)
 
  1) Duplicate the file and give it a useful name.
  2) Use ResEdit (or something similar) to make the following changes:
     - to simulate the pressing of command-F
 
	     Resource PDEF number 125
       (first always write to a "file")
           location       From       To
         v5.2   v6.0
         B96    C78       '57C0'    '51C0'
         B9A    C7C       '56C0'    '50C0'
         BA2    C84       '57C0'    '50C0'   ('51C0' for Laser Prep)
         BAA    C8C       '57C1'    '51C1'   ('50C1' for Laser Prep)
         BB8    C9A       '57C1'    '50C1'
          
       (next don't create a file (still in resource PDEF/125))
            location          From         To
          v5.2    v6.0    V5.2    V6.0
          D96     E9E    '554F'  '558F'   '6038'
     
       (next, don't do _SetEOF to empty said file)
            location          From        To
          v5.2    v6.0
          142C    1860       '660C'      '600C'
     
     - change the string in resource STR number -8159 to something more
       useful than "Creating PostScript File" (e.g. I used "Sending print
       job to NeXT").
 
     - set resource STR number -8191 to the name of the serial port you
       will use. ".BOut" for the printer port or ".AOut" for the modem port.
 
     - set resource PAPA number -8192 to the name of the printer if
        you want to.

  A couple of notes: the default settings for the serial ports are 9600 baud
  no parity. So far this has worked fine but I may try changing the speed.
  When you choose the driver with the Chooser, it will turn on AppleTalk. If
  you are using the printer port then you *must* turn AppleTalk back off
  before using the modified driver.
 

  On the Unix end: I modified macps to "break" instead of "continue" when
  it finds the string "%%EOF" and then the command
       macps < /dev/ttyb | lpr
  can be installed in a deamon that loops forever (modify /dev/ttyb to use
  whatever serial port on your Unix box you connected the Mac to).
 


----------------------- OTHER USEFUL INFORMATION -------------------------

(1) FORCING THE GENERATED FILE TO GO TO ONE DIRECTORY

Postscript files are normally stored in the folder of the application
that is currently running; If you have a telecom script (Red Ryder...)
that uploads your Postscript file, it may not find this file.  We
suggest you make the file go to a pre-specified folder on your hard
disk.  Edit you Laserwriter icon via ResEdit as follows:

	     Resource STR #-8191
		From		To

		"Postscript"	"HD40:Postscript"

This would put the file in the top-level directory of a hard disk
named "HD40".  Or if you just want all your files to go into a folder
named "Spool" on a disk named "HD40":

	     Resource STR #-8191
		From		To

		"Postscript"	"HD40:Spool:Postscript"

etc. etc. etc.

(2) WHAT TO DO WHEN YOU HAVE PROBLEMS PRINTING THE FILE ON A
NON-LASERWRITER

Apple's laserprep file crashes nearly all non-apple printers (Not
cool, apple).  Because of copyright law and lawyers, we can't just
give you a modified laser prep file.  Instead, we offer two ways to
get around this problem.  One, you can use a UNIX program ("prepfix")
that edits a laserprep file to fix the mistake.  Two, you could edit
the file yourself (it takes 5 minutes and a decent editing program).

METHOD 1.  These UNIX programs will (a) edit a Laserprep file for you,
and (b) concatenate an edited Laserprep file with a postscript file;
These programs are stored in
	[sumex-aim.stanford.edu]<info-mac>unix>macps-22.shar

This is a shar archive containing two programs.  The shar archive is
unpacked using the Bourne shell and provides various documentation and
build files as well as the two c programs -- prepfix and macps.  The
first processes the LaserPrep file produced by holding down <Apple+K>
whilst printing an empty file and transforms it into a prep file which
is acceptable to most Postscript printers.  The second, macps,
processes documents produced using the <Apple+F> key to include the
processed header file.  prepfix/macps allow for the possibility of
different versions of Apple's LaserPrep.  

METHOD 2.  Read the file 
	[sumex-aim.stanford.edu]<info-mac>tips>imagen-postscript.txt

This file tells you how to edit a laserprep file to work with most
printers (this isn't just for imagen printers, actually).  Note: Only
Apple printers have bitmap smoothing; this is not part of normal
postscript.  If you absolutely need bitmap smoothing, and your printer
has an MC68000-family processor, and you are using the laserwriter
v5.2 icon, consider downloading the following specially hand-modified
laserprep file:
	[sumex-aim.stanford.edu]<info-mac>misc>laserprep-65-postscript.txt.

This file SHOULD NOT be used with non-MC68000 printers; it contains
assembly-language code that could crash such printers.  

(3) YOU HAVE A POSTSCRIPT FILE ON YOUR MACINTOSH AND WANT TO GET IT TO
THE PRINTER --

A Postscript(R) file can be printed using three utilities: SendPS, a
free application from Adobe, archived in
	[sumex-aim.stanford.edu]<info-mac>util>sendps-121.hqx

Or use PS Printer, a free desk accessory; or Hyper PS, a Hypercard
stack for sending Postscript files to a Postscript printer.

gillies@m.cs.uiuc.edu (09/21/90)

		"imagen-postscript.txt" 

This file tells you how to modify a laserprep file to print on
non-apple postscript printers.  If you get a printing error saying
something about "setdefaulttimeouts", then you probably need to make
these modifications.  This file also works with the system 6.1 (color
quickdraw) printing tools.  It isn't just for imagen printers anymore!

Date: Tue, 22 Aug 89 16:56:08 -0500
From: Don Gillies <gillies@cs.uiuc.edu>
Message-Id: <8908222156.AA16954@p.cs.uiuc.edu>
To: info-mac@sumex-aim.stanford.edu
Subject: ImagenPostScript
Cc: gillies@cs.uiuc.edu

I can't access the archives right now; please add this file (I don't
think it's there now).  I suggest you call it "imagen-postscript.txt"
and put it in the tips directory.  I have re-posted this twice in one
week, to people requesting this information.  Thanks!  -- Don Gillies

---------------------------- cut here ------------------------

/* ---------- "Imagen postscript problems" ---------- */
I posed a question in these newsgroups on March 23, asking how to
get postscript files prepared on a Mac, to print properly on an
Imagen 2308S running 4.0 software with Ultrascript.  This posting
provides the solutions that were suggested by Imagen software support,
and several net readers.

The problem is in the dictionary provided by Apple.  The result of
doing an option-K on your Mac, just after clicking on OK in the print
dialogue box, is a postscript file which contains Apple's postscript
dictionary, followed by the output of the application you created a
drawing with.  The dictionary, which is the header of the file, looks like:

%!
%%Title: "Laser Prep -- The Apple PostScript Dictionary (md)"
%%Creator: Apple Software Engineering
%%CreationDate: Thursday, March 19, 1987
%{appledict version #68 0
% (c) CopyRight Apple Computer, Inc. 1984,1985,1986,1987,1988 All Rights Reserved.
%%EndComments
%%BeginProcSet: "(AppleDict md)" 68 0
	.
	.
	.
%%EndProcSet
%%EOF

There are two ways of dealing with this problem.  The first and
definitely the simplest, is simply to use Imagen's Apple compatibility
dictionary corresponding to the version of LaserPrep your Mac puts
out.  For LaserPrep 5.2, that means replacing the entire dictionary
shown above with the two lines:

%!
(dictv52.ps)run

"dictv5.ps", "dictv51.ps", and "dictv52.ps" are postscript dictionaries
which Imagen provides on their hard disk; you can use your Imagen disk
manager program to verify they're there.

The second (and more involved) way of dealing with the problem, is
to fixup Apple's dictionary.  Two fixups are needed.  The first fixup
is at approximately line 9 of the dictionary, which reads:

statusdict begin waittimeout 300 lt{0 60 300 setdefaulttimeouts}if end

This line attempts to set "statusdict" operators that are normally
protected, which results in an "invalidaccess" error on Imagen.
(I presume the LaserWriter must be executing something behind our
backs to get this to work as is.)
To fix it, either (1) place a "serverdict begin <password> exitserver"
command before the above line, or (2) comment out the above line by
placing a '%' before it.

The second needed fixup is at approximately lines 10 & 11 of the
dictionary.  To each of the strings "//setrealdevice" and "//execjob",
prepend a '%' (so they're commented out) and append a '\n' (newline).
(No, I don't know what "setrealdevice" and "execjob" do, they aren't
in Adobe's ps ref manual, appendix D.6 - SYSTEM PARAMETERS.  Must be
Apple-specific stuff.  If you know, please tell me too.)

I should probably mention that several persons pointed me at host
sumex-aim.stanford.edu, which contains contributed programs for the
Mac.  Specifically, they suggested that I look at "macps-prepfix.shar",
which contains programs "macps" and "prepfix", one of whose functions
is to prepend a standard Apple dictionary to a postscript program
on a unix host, before sending it to a LaserWriter.  These programs
aren't very useful with an Imagen, as it's a lot easier just to add
that "(dictv52.ps)run" command to your postscript files, before spooling
them to Imagen.
				******
I should probably also mention that one of the first problems we
encountered with postscript on our Imagens, had to do with
"invalidaccess" error messages not related to the above dictionary
problems.  Imagen already had a fix for this, which involves downloading
two files to your hard disk, "2020.ps" and "startup.ps", which change
some systemdict parameters ... related to memory allocation, I believe.
If you have an Imagen, plan on doing much future postscript work,
and haven't yet applied this fix, you can get it by calling Imagen or
e-mailing me.
-- 
--------
Ed Arnold * NCAR (Nat'l Center for Atmospheric Research) * Mesa Lab
PO Box 3000 * Boulder, CO  80307-3000 * 303-497-1253(w) * 303-494-6949(h)
era@ncar.ucar.edu (128.117.64.4) * {ames,gatech,noao,...}!ncar!era