29.	HARDCOPY FACILITIES

 
Interlisp-D includes facilities for generating hardcopy in "Interpress" format and "Press" format.  Interpress is a file format used for communicating documents to Xerox Network System printers such as the Xerox 8044 and Xerox 5700.  Press is a file format used for communicating documents to Xerox laser Xerographic printers known by the names "Dover", "Spruce", "Penguin", and "Raven".  There are also library packages available for supporting other types of printer formats (4045, FX-80, C150, etc.).  The hardcopy facilities are designed to allow the user to support new types of printers with minimal changes to the user interface.
Files can be in a number of formats, including Interpress files, plain text files, and formatted Tedit files.  In order to print a file on a given printer, it is necessary to identify the format of the file, convert the file to a format that the printer can accept, and transmit it.  Rather than require that the user explicitly determine file types and do the conversion, the Interlisp-D hardcopy functions generate Interpress or other format output depending on the appropriate choice for the designated printer.  The hardcopy functions use the variables PRINTERTYPES and PRINTFILETYPES (described below) to determine the type of a file, how to convert it for a given printer, and how to send it.  By changing these variables, the user can define other kinds of printers and print to them using the normal hardcopy functions.
(SEND.FILE.TO.PRINTER FILE HOST PRINTOPTIONS)  	[Function]
The function SEND.FILE.TO.PRINTER causes the file FILE to be sent to the printer HOST.  If HOST is NIL, the first host in the list DEFAULTPRINTINGHOST which can print FILE is used.
PRINTOPTIONS is a property list of the form (PROP1 VALUE1 PROP2 VALUE2 ...).  The properties accepted depends on the type of printer.  For Interpress printers, the following properties are accepted:
	DOCUMENT.NAME	The document name to appear on the header page (a string).  Default is the full name of the file.
	DOCUMENT.CREATION.DATE	The creation date to appear on the header page (a Lisp integer date, such as returned by IDATE).  The default value is the creation date of the file.
	SENDER.NAME	The name of the sender to appear on the header page (a string).  The default value is the name of the user.
	RECIPIENT.NAME	The name of the recipient to appear on the header page (a string).  The default is none.
	MESSAGE	An additional message to appear on the header page (a string).  The default is none.
	#COPIES	The number of copies to be printed.  The default value is 1.
	PAGES.TO.PRINT	The pages of the document that should be printed, represented as a list (FIRSTPAGE# LASTPAGE#).  For example, if this option is (3 5), this specifies that pages 3 through 5, inclusive, should be printed.  Note that the page numbering used for this purpose has no connection to any page numbers that may be printed on the document.  The default is to print all of the pages in the document.
	MEDIUM	The medium on which the master is to be printed.  If omitted, this defaults to the value of NSPRINT.DEFAULT.MEDIUM, as follows:  NIL means to use the printer's default; T means to use the first medium reported available by the printer; any other value must be a Courier value of type MEDIUM.  The format of this type is a list (PAPER (KNOWN.SIZE TYPE)) or (PAPER (OTHER.SIZE (WIDTH LENGTH))).  The paper TYPE is one of US.LETTER, US.LEGAL, A0 through A10, ISO.B0 through ISO.B10, and JIS.B0 through JIS.B10.  For users who use A4 paper exclusively, it should be sufficient to set NSPRINT.DEFAULT.MEDIUM to (PAPER (KNOWN.SIZE "A4")).
When using different paper sizes, it may be necessary to reset the variable DEFAULTPAGEREGION, the region on the page used for printing (measured in micas from the lower-left corner).
	STAPLE?	True if the document should be stapled.
	#SIDES	1 or 2 to indicate that the document should be printed on one or two sides, respectively.  The default is the value of EMPRESS#SIDES.
	PRIORITY	The priority of this print request, one of LOW, NORMAL, or HIGH.  The default is the printer's default.
Note:  Press printers only recognize the options #COPIES, #SIDES, DOCUMENT.CREATION.DATE, and DOCUMENT.NAME.
For example,
(SEND.FILE.TO.PRINTER 'FOO NIL
   '(#COPIES 3 #SIDES 2 DOCUMENT.NAME "For John"))
SEND.FILE.TO.PRINTER calls PRINTERTYPE and PRINTFILETYPE to determine the printer type of HOST and the file format of FILE.  If FILE is a formatted file already in a form that the printer can print, it is transmitted directly.  Otherwise, CONVERT.FILE.TO.TYPE.FOR.PRINTER is called to do the conversion.  [Note:  If the file is converted, PRINTOPTIONS is passed to the formatting function, so it can include properties such as HEADING, REGION, and FONTS.]  All of these functions use the lists PRINTERTYPES and PRINTFILETYPES to actually determine how to do the conversion.
LISTFILES (page X.XX) calls the function LISTFILES1 to send a single file to a hardcopy printing device.  Interlisp-D is initialized with LISTFILES1 defined to call SEND.FILE.TO.PRINTER. 

(HARDCOPYW WINDOW/BITMAP/REGION FILE HOST SCALEFACTOR ROTATION PRINTERTYPE)  	[Function]
Creates a hardcopy file from a bitmap and optionally sends it to a printer.  Note that some printers may have limitations concerning how big or how "complicated" the bitmap may be printed.
WINDOW/BITMAP/REGION can either be a WINDOW (open or closed), a BITMAP, or a REGION (interpreted as a region of the screen).  If WINDOW/BITMAP/REGION is NIL, the user is prompted for a screen region using GETREGION.
If FILE is non-NIL, it is used as the name of the file for output.  If HOST=NIL, this file is not printed.  If FILE is NIL, a temporary file is created, and sent to HOST.
To save an image on a file without printing it, perform (HARDCOPYW IMAGE FILE).  To print an image to the printer PRINTER without saving the file, perform  (HARDCOPYW IMAGE NIL PRINTER).  
If both FILE and HOST are NIL, the default action is to print the image, without saving the file.  The printer used is determined by the argument PRINTERTYPE and the value of the variable DEFAULTPRINTINGHOST.  If PRINTERTYPE is non-NIL, the first host on DEFAULTPRINTINGHOST of the type PRINTERTYPE is used.  If PRINTERTYPE is NIL, the first printer on DEFAULTPRINTINGHOST that implements the BITMAPSCALE (as determined by PRINTERTYPES, page X.XX) operation is used, if any.  Otherwise, the first printer on DEFAULTPRINTINGHOST is used.
The type of hardcopy file produced is determined by HOST if non-NIL, else by PRINTERTYPE if non-NIL, else by the value of DEFAULTPRINTINGHOST, as described above. 
SCALEFACTOR is a reduction factor.  If not given, it is computed automatically based on the size of the bitmap and the capabilities of the printer type.  This may not be supported for some printers.
ROTATION specifies how the bitmap image should be rotated on the printed page.  Most printers (including Interpress printers) only support a ROTATION of multiples of 90.
PRINTERTYPE specifies what type of printer to use when HOST is NIL.  HARDCOPYW uses this information to select which printer to use or what print file format to convert the output into, as described above.
The background menu contains a "Hardcopy" command (page X.XX) that prompts the user for a region on the screen, and sends the image to the default printer.

Hardcopy output may also be obtained by writing a file on the printer device LPT, e.g. (COPYFILE 'FOO '{LPT}).  When a file on this device is closed, it is converted to Interpress or some other format (if necessary) and sent to the default printer (the first host on DEFAULTPRINTINGHOST).  One can include the printer name directly in the file name, e.g. (COPYFILE 'FOO {LPT}TREMOR:) will send the file to the printer TREMOR:.
(PRINTERSTATUS PRINTER)  	[Function]
Returns a list describing the current status of the printer named PRINTER.  The exact form of the value returned depends on the type of printer.  For Interpress printers, the status describes whether the printer is available or busy or needs attention, and what type of paper is loaded in the printer.
Returns NIL if the printer does not respond in a reasonable time, which can occur if the printer is very busy, or does not implement the printer status service.

DEFAULTPRINTINGHOST  	[Variable]
The variable DEFAULTPRINTINGHOST is used to designate the default printer to be used as the output of printing operations.  It should be a list of the known printer host names, for example, (QUAKE LISPPRINT:).  If an element of DEFAULTPRINTINGHOST is a list, is interpreted as (PRINTERTYPE HOST), specifying both the host type and the host name.  The type of the printer, which determines the protocol used to send to it and the file format it requires, is determined by the function PRINTERTYPE.  
If DEFAULTPRINTINGHOST is a single printer name, it is treated as if it were a list of one element.

(PRINTFILETYPE FILE  )  	[Function]
Returns the format of the file FILE.  Possible values include INTERPRESS, TEDIT, etc.  If it cannot determine the file type, it returns NIL.  Uses the global variable PRINTFILETYPES.

(PRINTERTYPE HOST)  	[Function]
Returns the type of the printer HOST.  Currently uses the following heuristic: (1) If HOST is a list, the CAR is assumed to be the printer type and CADR the name of the printer; (2) If HOST is a litatom with a non-NIL PRINTERTYPE property, the property value is returned as the printer type; (3) If HOST contains a colon (e.g., PRINTER:PARC:XEROX) it is assumed to be an INTERPRESS printer; (4) if HOST is the CADR of a list on DEFAULTPRINTINGHOST, the CAR is returned as the printer type; (5) otherwise, the value of DEFAULTPRINTERTYPE is returned as the printer type.


29.1  	Low-level Hardcopy Variables

The following variables are used to define how Interlisp should generate hardcopy of different types.  The user should only need to change these variables when it is necessary to access a new type of printer, or define a new hardcopy document type (not often).
PRINTERTYPES  	[Variable]
The characteristics of a given printer are determined by the value of the list PRINTERTYPES.  Each element is a list of the form
(TYPES (PROPERTY1 VALUE1) (PROPERTY2 VALUE2) ...)
TYPES is a list of the printer types that this entry addresses.  The (PROPERTYn VALUEn) pairs define properties associated with each printer type.
The printer properties include the following:
	CANPRINT	Value is a list of the file types that the printer can print directly.
	STATUS	Value is a function that knows how to find out the status of the printer, used by PRINTERSTATUS (page X.XX).
	PROPERTIES	Value is a function which returns a list of known printer properties.
	SEND	Value is a function which invokes the appropriate protocol to send a file to the printer.
	BITMAPSCALE	Value is a function of arguments WIDTH and HEIGHT in bits which returns a scale factor for scaling a bitmap.
	BITMAPFILE	Value is a form which, when evaluated, converts a bitmap to a file format that the printer will accept.
Note:  The name 8044 is defined on PRINTERTYPES as a synonym for the INTERPRESS printer type.  The names SPRUCE, PENGUIN, and DOVER are defined on PRINTERTYPES as synonyms for the PRESS printer type.  The printer types FULLPRESS and RAVEN are also defined the same as PRESS, except that these printer types indicate that the printer is a "Full Press" printer that is able to scale bitmap images, in addition to the normal Press printer facilities.

PRINTFILETYPES  	[Variable]
The variable PRINTFILETYPES contains information about various file formats, such as Tedit files and Interpress files.  The format is similar to PRINTERTYPES.  The properties that can be specified include:
	TEST	Value is a function which tests a file if it is of the given type.  Note that this function is passed an open stream.
	CONVERSION	Value is a property list of other file types and funcitons that convert from the specified type to the file format.
	EXTENSION	Value is a list of possible file extensions for files of this type.


Copyright (c) 1985 Xerox Corporation.  All rights reserved.