with-output-to-printer

Macro

Package: common-graphics

Arguments: (stream-var &rest printer-args&key units-per-inch font cancel-value &allow-other-keys) &body body

Executes body with stream-var bound to a newly-opened printer stream. The printer-args parameter allows any initargs that would be passed to open-stream for a printer to be passed to this macro. In addition, if units-per-inch is specified true, then the stream-units-per-inch of the printer stream is set to this value before executing body. If a font is passed, then the font of the printer stream is set to this font before executing body (just after the stream-units-per-inch is set, if this is also done).

When the printer stream is opened, the end user is presented with the printer job dialog as usual (unless the :no-dialog-p printer-arg is passed as true). If the user cancels from this dialog, then cancel-value is returned from the with-output-to-printer form.

Otherwise the values returned by the last form in body are returned. An unwind-protect ensures that the printer stream always gets closed.

The following example does the following:

1. opens a printer stream,

2. sets its stream-units-per-inch to 100 (which scales it approximately the same as a video monitor),

3. sets its font to be a large arial font which is 48 of these stream units tall,

4. prints "A Large String" on the printer stream,

5. and then closes the printer stream (which ejects the output).

> (with-output-to-printer (p :units-per-inch 100
			     :font (make-font-ex nil :arial 48))
     (print "A Large String" p))[returns] "A Large String"

Common Graphics and IDE documentation is described in About Common Graphics and IDE documentation in cgide.htm.

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.