The JHU/APL IDL library routine psinit makes it easy to deal with one or more PostScript printers. Calling psinit redirects further graphics to the specified printer, actually a file to be sent to the printer. The sister routine, psterm terminates the PostScript output, sends the result to the specified printer, and resets the graphics output back to what is was.
The following text describes how to set up the printer description file used by psinit.
The PostScript printers on the system are known to the IDL routine
psinit through the environmental variable IDL_PSPRINTERS.
IDL_PSPRINTERS names a file describing the Postscript
printers available on the system. The format of that file is:
* Any comments start with * as first char.
* Comment lines are ignored.
lpr -Pcolor7_383 <-- print command.
Phaser 860 Color Print in room 7-383 <-- printer description.
lpr -Pcolor7_383t <-- next printer comand.
Phaser 860 Color Transparency in room 7-383. <-- its description.
. . . <-- as many pairs as needed.
An example file for 5 print queues is:
*--- IDL Postscript printers description file --------
* R. Sterner, 13 Aug, 1991 S1R group system
* R. Sterner, 1997 Oct 02 updated for building 7.
* R. Sterner, 2000 Nov 22 updated for linux on zero.
* R. Sterner, 2004 May 12 Dropped old printers.
lpr -Pcolor7_383
Phaser 860 Color Print in room 7-383.
lpr -Pcolor7_383t
Phaser 860 Color Transparency in room 7-383.
lpr -Pplot7_384
HP Laserjet B&W PS 600 dpi printer in room 7-384.
lpr -Pcolor_450
Phaser 450 Color Print in 7-383
lpr -Pcolor_450t
Phaser 450 Color Transparency in 7-383
-=-=-=-=- Some notes on the May 1995 upgrade to psinit -=-=-=-=-
Two major changes were made to psinit:
* An additional method of selected a printer is available.
* Color PostScript is now supported.
In the past a PS printer was specified by its number as shown
in the list given by psinit,/list. This still works. In addition
a PS printer may now be specified by a tag name. This can
be any string in the printer description. Printer descriptions are
displayed by the command psinit,/list. These are from the text file
pointed to by the environmental variable IDL_PSPRINTERS. It may be
useful to edit these descriptions to add unique printer tags.
If the given tag name does not occur in any of the printer descripton
lines the psinit command is ignored. If it occurs in more than
one printer descripton line the first match is used but a warning
message is given.
Color PostScript is now supported by the addition of three new
keywords:
/COLOR means do color PostScript (def is B&W).
/AUTOCOLOR means automatically set color mode for a
color PS printer. Must have the word color in the
printer description line.
CFLAG=flag Returned color flag: 0=B&W, 1=Color mode.
/COLOR just attempts to place the printer in color mode.
/AUTOCOLOR is more interesting. It only sets color mode if
the printer is actually a color printer. This is determined
by looking for the word color somewhere in the printer description
line. So this word must appear in the description for this
keyword to work. This keyword may be given to any printer,
even if it's black and white. The returned flag value, CFLAG,
will be 0 for B&W and 1 for a color printer. This is useful
if the images must be treated differently for the two cases.
For example, if the color image currently displayed in a graphics
window is to be sent to a B&W printer it should first be converted
to luminosity as follows:
a = tvrd() ; Read the current image.
tvlct,r,g,b,/get ; Read its color table.
lum = ROUND(.3*r + .59*g + .11*b)<255 ; Find image brightness.
a = lum(a) ; Convert color image to B&W.
The converted image, a, should print ok on a B&W printer.
Redirect plots and images to postscript printer.
psinit [,num]
num = Postscript printer number. in
This may alternately be any unique string in the
printer description displayed using /LIST.
Keywords:
/FULL to use full page in portrait mode (def=top half).
/LANDSCAPE to do plot in landscape mode.
/COLOR means do color PostScript (def is B&W).
/AUTOCOLOR means automatically set color mode for a
color PS printer. Must have the word color in the
printer description line.
CFLAG=flag Returned color flag: 0=B&W, 1=Color mode.
FILE=f redirect plot to a specified file. The default
is idl.ps in the local directory.
DEFAULT=dn Set default printer number (def=0).
Stays in effect for IDL session.
MARGIN = [left, right, bottom, top] sets margins (inches).
May give as few values as needed. For left margin only
may just use MAR=xxx, otherwise give an array.
WINDOW = [xmin, xmx, ymin, ymx] sets window (inches).
Must give all 4 values.
/CENTIMETERS interpreted margin or window values in cm.
/DOUBLE to do plot in double thickness.
/VECTOR to use vector fonts instead of postscript fonts.
/ORIGIN plots a mark at the page origin.
/QUIET turns off psinit messages.
/LIST_PRINTERS lists available printers and their numbers.
COMMENT=txt comment to print with the time stamp.
Notes:
Default is portrait mode, top half of page.
Related routines:
psterm - terminate postscript output and make plots.
pspaper - plot norm. coord. system for curr. page setup.
Terminate postscript plotting and send plots to printer. psterm No arguments. Plots are sent to the printer that was selected with psinit. See psinit. Keywords: /NOPLOT terminates without plotting. /QUIET turns off psterm messages. /LAST plots existing idl.ps file (usually last plot). /NOSTAMP suppresses default user name and time stamp. /CLEAR_COMMENT clears comment after listing it.
Plot a postscript layout sheet. Gives normalized coordinate system. pspaper No args. Note: Call psinit with desired page format and margin. Then call pspaper.
color,'sky blue',10
Then doing a plot or oplot using color=10 will plot in Sky Blue. The colors known to color may be listed by color,/list. If psterm,/noplot is used the plot may be previewed before printing using $gs idl.ps or $gv idl.ps.