{Begin SubSec HardCopy Facilities}
{Title HardCopy Facilities}
{Text

Interlisp-D includes facilities for generating hardcopy in both "Press" and "Interpress" formats.  Press is a file format used for communicating documents to Xerox prototype laser Xerographic printers known by the names "Dover", "Spruce", "Penguin", and "Raven".  Interpress is a file format used for communicating documents to Xerox Network System printers such as the Xerox 8044 and Xerox 5700.

Files can be in a number of formats: Interpress and Press 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 Press or Interpress output depending on the appropriate choice for the designated printer.  The hardcopy functions use the variables {var PRINTERTYPES} and {var 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.

{FnDef {Name SEND.FILE.TO.PRINTER} {Args FILE HOST PRINTOPTIONS}
{Text
The function {fn SEND.FILE.TO.PRINTER} causes the file {arg FILE} to be sent to the printer {arg HOST}.  If {arg HOST} is {lisp NIL}, the first host in the list {var DEFAULTPRINTINGHOST} which can print {arg FILE} is used.

{arg PRINTOPTIONS} is a property list of the form {lisp ({arg PROP1} {arg VALUE1} {arg PROP2} {arg VALUE2} {ellipsis})}.  Properties can include: {lisp HEADING} - a string to use on the top of each page; {lisp #COPIES} - the number of copies of the file to print; {lisp #SIDES} - if 2, select two-sided printing (if {arg HOST} can print two-sided copies); {lisp DOCUMENT.NAME} - the 'name' of the document, which often appears on a cover sheet.  For example,

{lispcode
(SEND.FILE.TO.PRINTER 'FOO NIL
   '(#COPIES 3 #SIDES 2 DOCUMENT.NAME "For John"))} 

{fn SEND.FILE.TO.PRINTER} calls {fn PRINTERTYPE} and {fn PRINTFILETYPE} to determine the printer type of {arg HOST} and the file format of {arg FILE}.  If {arg FILE} is a formatted file (e.g., already in Press or Interpress format) in a form that the printer can print, it is transmitted directly.  Otherwise, {fn CONVERT.FILE.TO.TYPE.FOR.PRINTER} is called to do the conversion.  All of these functions use the lists {var PRINTERTYPES} and {var PRINTFILETYPES} to actually determine how to do the conversion.

{fn LISTFILES} calls the function {fn LISTFILES1} to send a single file to a hardcopy printing device.  Interlisp-D is initialized with {fn LISTFILES1} defined to call {fn SEND.FILE.TO.PRINTER}. 

Note:  For backwards compatibility, the function {fn EMPRESS} is defined to pack its arguments into a list, and call {fn SEND.FILE.TO.PRINTER}.
}}



{Fndef {name HARDCOPYW} {args WINDOW/BITMAP/REGION FILE HOST SCALEFACTOR ROTATION PRINTERTYPE}
{text
Creates a hardcopy file from a bitmap and optionally sends it to a printer.  {ARG WINDOW/BITMAP/REGION} can either be a {lisp WINDOW} (open or closed), a {lisp BITMAP}, or a {lisp REGION} (interpreted as a region of the screen).  If {lisp NIL}, the user is prompted for a screen region using {fn GETREGION}.

If {arg FILE} is non-{lisp NIL}, it is used as the name of the file for output.  If {arg HOST}={lisp NIL}, this file is not printed.

If {arg FILE} is {lisp NIL}, output is sent to {arg HOST}.  If {arg HOST} is {lisp NIL}, the first host on {var DEFAULTPRINTINGHOST} of the type {arg PRINTERTYPE} is used.

To save an image on a file without printing it, perform {lisp (HARDCOPYW {arg IMAGE} {arg FILE})}.  To print an image without saving the file, perform {lisp (HARDCOPYW {arg IMAGE})}, or, to send it to a specific printer, {lisp (HARDCOPYW {arg IMAGE} NIL {arg PRINTER})}.  

{arg 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.   

{arg ROTATION} specifies how the bitmap image should be rotated on the printed page.  Most printers (including current {lisp INTERPRESS} and {lisp PRESS}) only support a {arg ROTATION} of multiples of 90.

{arg PRINTERTYPE} specifies what 'kind' of printer to use in environments that have more than one kind of printer around.  For example, if you specify {arg PRINTERTYPE} to be {lisp PRESS} or {lisp INTERPRESS}, {fn HARDCOPYW} will use that information to select which printer to use or what print file format to convert the output into.  If {arg PRINTERTYPE} is {lisp NIL}, it defaults to {lisp INTERPRESS}.

Note that the "Hardcopy" command in the background menu merely evaluates {lisp (HARDCOPYW)}, which prompts the user for a region on the screen, and sends the image to the default printer.  The "Hardcopy" command in the paint menu performs {lisp (HARDCOPYW {arg WINDOW})}, which sends an image of the whole window to the default printer.
}}


{VarDef {Name DEFAULTPRINTINGHOST} 
{Text
The variable {var 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, {lisp (QUAKE LISPPRINT:)}.  If an element of {var DEFAULTPRINTINGHOST} is a list, is interpreted as {lisp ({arg PRINTERTYPE} {arg 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 {lisp PRINTERTYPE}.  

If {var DEFAULTPRINTINGHOST} is a single printer name, it is treated as if it were a list of one element.
}}

{FnDef {Name PRINTFILETYPE} {Args FILE}
{Text
Returns the format of the file {arg FILE}.  Possible values include {lisp PRESS}, {lisp INTERPRESS}, {lisp TEDIT}, etc.  If it cannot determine the file type, it returns {lisp NIL}.  Uses the global variable {lisp PRINTFILETYPES}.
}}

{FnDef {Name PRINTERTYPE} {args HOST}
{Text
Returns the type of a printer {arg HOST}.  Currently uses the following simple heuristic: printers whose name have a colon in them (e.g., {lisp PRINTER:PARC:XEROX}) are assumed to be {lisp INTERPRESS} printers.   If {arg HOST} is a list, the {fn CAR} is assumed to be the printer type and {fn CADR} the name of the printer, e.g., {lisp (PRESS LASSEN)}.  Otherwise, the printer is assumed to be the type which is the value of {var DEFAULTPRINTERTYPE},{index DEFAULTPRINTERTYPE Var} initially {lisp PRESS}.
}}


{VarDef {Name PRINTERTYPES}
{Text
The characteristics of a given printer are determined by the value of the list {var PRINTERTYPES}.  Each element is a list of the form

{lispcode
({arg TYPES} ({arg PROPERTY1} {arg VALUE1}) ({arg PROPERTY2} {arg VALUE2}) {ellipsis})}

{arg TYPES} is a list of the printer types that this entry addresses.  The {lisp ({arg PROPERTYn} {arg VALUEn})} pairs define properties associated with each printer type.

{var PRINTERTYPES} initially contains entries for the printer types {lisp INTERPRESS} (or {lisp 8044}), {lisp PRESS} ({lisp SPRUCE}, {lisp PENGUIN}, {lisp DOVER}), {lisp FULLPRESS} ({lisp RAVEN}).

The printer properties include {lisp CANPRINT} - a list of the file types that the printer can print directly; {lisp STATUS} - a function that knows how to find out the status of the printer, used by {fn PRINTERSTATUS}; {lisp PROPERTIES} - a function which returns a list of known printer properties; {lisp SEND} - a function which invokes the appropriate protocol to send a file to the printer; {fn BITMAPSCALE} - a function of arguments {arg WIDTH} and {arg HEIGHT} in bits which returns a scale factor for scaling a bitmap; and {lisp BITMAPFILE} - a form which, when evaluated, converts a {lisp BITMAP} to a file format that the printer will accept. 
}}

{VarDef {Name PRINTFILETYPES}
{Text
The variable {var PRINTFILETYPES} contains information about various file formats, such as Tedit files, Press files, and Interpress files.  The format is similar to {var PRINTERTYPES}.  The properties that can be specified include {lisp TEST} - a function which tests a file if it is of the given type; {lisp CONVERSION} - a property list of other file types and ways to convert from one to the other; and {lisp EXTENSION} - a list of possible file extensions for files of this type.
}}


Hardcopy output may also be obtained by writing a file on the printer device {lisp LPT},{index LPT (printer device)} e.g. {lisp (COPYFILE 'FOO '{bracket LPT})}.  When a file on this device is closed, it is converted to Press or Interpress format (if necessary) and sent to the default printer (the first host on {arg DEFAULTPRINTINGHOST}).  Thus, {lisp {bracket LPT}} acts like the device {lisp LPT:} in Interlisp-10.  One can include the printer name directly in the file name, e.g. {lisp (COPYFILE 'FOO {bracket LPT}QUAKE)} will send the file to the printer {lisp QUAKE}.


{Begin Note}
From Intermezzo Release Notes:
Star-compatible Interpress filetype used when creating, detecting Interpress files on NS file servers
Files on NS file servers have an associated numerical file type.  Interlisp does not normally use these file types, although the user can read and set them (using the FILETYPE file attribute).  However, this causes problems when accessing files from the Star workstation, which does use the filetypes.  Specifically, Star didn't recognize Interpress files generated from Interlisp, because they didn't have the right filetype (4361).  Therefore, Interlisp now creates Interpress files with the standard Interpress filetype.  This filetype is also used in INTERPRESSFILEP to quickly detect whether a file is an Interpress file: if the filetype is correct, Interlisp won't try parsing the file to see if it is a valid Interpress file.
{End Note}

}{End SubSec HardCopy Facilities}