For Direct Graphics printer and plotter devices (e.g., PCL, PostScript, and HP-GL), IDL creates a file containing output commands. This file can be sent to the printer via the normal methods provided by the local operating system. When attempting to output the file before exiting IDL, the user must be sure that the graphics output file is complete. For example, the following IDL commands (executed under UNIX) will not produce the desired result:
SET_PLOT,'PS' PLOT,x,y SPAWN,'lpr idl.ps'
These commands fail because the attempt to print the file is premature-the file is still open within IDL and is not yet complete.
The following lines of code are an IDL procedure called OUTPUT_PLOT which closes the current graphics file and sends it to the printer. This routine assumes that the graphics output file is named
xxx represents the name of the graphics driver. For example, PostScript output file is assumed to be
idl.ps. It also assumes that the graphics output to be printed is from the current graphics device, as selected with SET_PLOT.
; Close the current graphics file, and print it. If the ; New_file parameter is present, rename the file to the given ; name so it won't be overwritten: Pro OUTPUT_PLOT, New_file ; Close current graphics file: DEVICE,/CLOSE ; Build the default output file name by using the idl name for ; the current device
(!D.NAME):file = 'idl.' + STRLOWCASE (!D.NAME); Build shell commands to send file to the printer. ; You will probably have to change this command in accordance ; with local usage: cmd = 'lpr ' + file ; Concatenate rename command if new file specified: IF N_ELEMENTS(New_file) GT 0 THEN $ cmd = cmd + '; mv' + file + ' ' + New_file ; Issue shell commands to print/rename file: SPAWN, cmd END
The call to DEVICE causes IDL to finish the file and close it, which makes it available for printing.
In order for IDL generated output files to work properly with printers and plotters, it is necessary for the device to be configured properly. This usually involves configuring both the device hardware and the operating system printing software. When setting up your system, keep the following points in mind:
Many printers have a large buffer into which they store incoming data they haven't yet processed. This reduces the need to invoke flow control. When testing your configuration to ensure flow control is actually enabled, you must be sure to print a document long enough to fill any such buffer, or flow control may never occur, giving a false impression that the setup is correct. A common source of problems stem from attempting to print long IDL generated output files without proper flow control.
If you are having problems printing on a PostScript printer, the
ehandler.ps file in the
resource/fonts/ps subdirectory of the IDL distribution can help you to debug your problem. Sending this file to your PostScript Printer causes it to print any subsequent errors it encounters on a sheet of paper and eject it. The effect of this file lasts until the printer is reset.
Printers are configured in the
/etc/printcap file. This file describes to the system which printers are connected to it, the characteristics of each printer, and how the printer port should be configured. Managing the printcap file is usually discussed in the system management documentation supplied with the system by the manufacturer.
The difference between the XOFFSET and YOFFSET keywords to the DEVICE procedure, and the higher level plot positioning keywords and system variables (discussed in Graphics Keywords and "Direct Graphics Plotting" in the Using IDL manual) can lead to confusion. A common misunderstanding is to attempt to use the DEVICE procedure "offset" and "size" keywords multiple times in an attempt to produce multiple plots on a single output page.
The DEVICE keywords are intended to specify the size and position of the entire output area on the page, not to move the plotting region for multiple plots. The driver does not monitor their values continuously, but only when initializing a new page or ejecting the current one.
The proper way to produce multiple plots is to use the high level positioning abilities. The
Graphical output that is displayed with a black background on a monitor frequently look better if the background is changed to white when printed on white paper. This is easily done using the BACKGROUND graphics keyword or (if the only values displayed in black are in the background) with a statement like:
a(WHERE(a EQ 0B)) = 255B