{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 as the "Dover", "Penguin", "Raven".  "Interpress" is a file format used for communicating documents to Xerox Network System printers such as the Xerox 8044 and Xerox 5700.  The hardcopy functions below will generate Press or Interpress output depending on the appropriate choice for the designated printer. The user can define other kinds of printers and interface them with the print-file conversion software.

{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 can be either a single printer name or a list of names, for example, {lisp (QUAKE LISPPRINT:)}.  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}.
}}


{FnDef {Name PRINTERTYPE} {args HOST}
{Text
The function {fn PRINTERTYPE} is used to find the type of a printer.  The current implementation has 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 consists of a list, the {fn CAR} of which is a list of printer types, and the rest a list of (property value). The initial Interlisp-D system knows about printer types {lisp INTERPRESS} (e.g., Xerox {lisp 8044}), {lisp PRESS} ({lisp SPRUCE}, {lisp PENGUIN}, {lisp DOVER}), {lisp FULLPRESS} ({lisp RAVEN}).  The properties include {lisp CANPRINT} - the kinds of files 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 functional argument which returns a list of known printer properties, {lisp SEND} - a function argument 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} similarly contains some properties for various file formats, including {lisp TEST} - a function which tests a file if it is of the given type, - {lisp CONVERSION} which is a property list of other file types and ways to convert from one to ther other; and {lisp EXTENSION} a default file extension for files of this type.
}}


The function {fn LISTFILES1} is used by {fn LISTFILES} 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}. 


{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 value of {lisp DEFAULTPRINTINGHOST} is used -- if {lisp DEFAULTPRINTINGHOST} is a list, the first host in the list which can print {arg FILE} is selected.  {arg PRINTOPTIONS} is a 'property list' of options of the form {lisp ({arg optionname} {arg optionvalue} ...)}. Option names 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, {lisp (EMPRESS 'FOO NIL '(#COPIES 3 #SIDES 2 DOCUMENT.NAME "For John"))} 

If {arg FILE} is a formatted file (e.g., already in Press or Interpress format), it is transmitted directly. {fn SEND.FILE.TO.PRINTER} uses the sub-functions {fn PRINTERTYPE} to determine the printer type of {arg HOST}, and {fn PRINTFILETYPE} to determine the file format of {arg FILE}. It then calls {fn CAN.PRINT.DIRECTLY} to determine if a printer of the given type can directly print the file, or else calls {fn CONVERT.FILE.TO.TYPE.FOR.PRINTER} to do the conversion. All of these functions use the lists {var PRINTERTYPES} and {var PRINTFILETYPES} to actually determine how to do the conversion. This was designed to make the Interlisp-D hardcopy facilities deal gracefully with a variety of printer types and file formats.
}}

{FnDef {Name CONVERT.FILE.TO.TYPE.FOR.PRINTER} {Args FILE FILETYPE PRINTERTYPE HEADING}}
{Text
This function converts the input {arg FILE} into a type which is acceptable to a printer of type {arg PRINTERTYPE}, e.g., a Press or Interpress file.  The list {var PRINTFILETYPES} is used to determine how to do the conversion.

In general, the conversion functions from files of type {lisp TEXT} recognize some special character sequences. Character sequences beginning with control-F (ASCII 6) as special formatting instructions.  If the code of the next character is a valid font number, then the formatting sequence indicates a change to that font.  The correspondence between font numbers and fonts is specified by entries on the current font profile list (see {PageRef Tag FontProfile}). {arg HEADING} is a string that is printed as a heading on each page.  If {arg HEADING} is {lisp NIL}, the file's name and creation date will be used.

If the control-F is followed by a control-T, the code of the character after that is interpreted as an absolute tab stop number. The corresponding entry on the list {var PRESSTABSTOPS}{index PRESSTABSTOPS Var} is taken as the number of mills from the left margin at which printing on the current line will continue.  {var PRESSTABSTOPS} is initially {lisp (8000)}.
}}

{VarDef {Name FONTWIDTHSFILES}
{Text
Value is a file name or a list of file names to be searched for information about the widths of characters in particular fonts.  This variable should be initialized in the site greeting file.
}}

{Fndef {name HARDCOPYW} {args WINDOW/BITMAP/REGION FILE HOST SCALEFACTOR ROTATION PRINTERTYPE}
{text
Creates bitmap hardcopy 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 region using {fn GETREGION} ({PageRef Fn GETREGION}) in a manner which "defaults" to the whole screen.

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

When {arg FILE} is {lisp NIL}, output will be sent to {arg HOST} or (the first printer on) {var DEFAULTPRINTINGHOST}.

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} {lisp 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 (see the discussion of {lisp PRINTERTYPE}.)   

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

Note that "Hardcopy" in the background menu merely performs {lisp (HARDCOPYW)}, which sends an image of region user selects to the default printer.  Hardcopy in the paint menu performs {lisp (HARDCOPYW {arg WINDOW})}, which sends an image of window to the default printer.
}}


{FnDef {Name PRINTFILETYPE} {Args FILE}
{Text
Attempts to determine the print format that {arg FILE} is in. Uses the information in the global variable {lisp PRINTFILETYPES}{index PRINTFILETYPES (variable)}, which specifies, for each kind of printable file, a predicate (e.g., Interpress files are tested by {fn INTERPRESSFILEP}{index INTERPRESSFILEP (function)} while press files are recognized by {fn PRESSFILEP}), and conversion functions.
}



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.  Thus, {lisp {bracket LPT}} acts like the device {lisp LPT:} in Interlisp-10.  One can name the printer directly as the file name, e.g. {lisp {bracket LPT}QUAKE} to talk about the printer {lisp QUAKE}.

}{End SubSec HardCopy Facilities}