All Manuals > Common Lisp Interface Manager 2.0 User's Guide > Appendix D Common Lisp Streams

D.6 Hardcopy Streams in CLIM

CLIM supports hardcopy output through the macro with-output-to-postscript-stream .


Arguments: (stream-var file-stream &key (:display-device clim::*postscript-device* ) :header-comments :multi-page) &body body

Summary: Within body, stream-var is bound to a stream that produces PostScript code.

The following example writes a PostScript program that draws a square, a circle, and a triangle to a file named .

(defun print-icons-of-high-tech-to-file ()
      (file-stream "" :direction :output)
     (stream file-stream)
     (let* ((x1 150) (y 250) (size 100)
            (x2 (+ x1 size))
            (radius (/ size 2))
            (base-y (+ y (/ (* size (sqrt 3)) 2))))
      (clim:draw-rectangle* stream
                            (- x1 size) (- y size)
                            x1 y)
      (clim:draw-circle* stream
                         (+ x2 radius) (- y radius)
      (clim:draw-triangle* stream
                           (+ x1 radius) y
                           x1 base-y
                           x2 base-y)))))

The second example uses multi-page mode to draw a graph of the superclasses of the class window-stream by writing a PostScript program to the file some-pathname .

(with-open-file (file some-pathname :direction :output)
   (stream file :multi-page t)  
    (clos:find-class 'clim-internals::window-stream)
    #'(lambda (object s)
       (write-string (string (clos:class-name object)) s))
    :stream stream)))

Note that with-output-to-postscript-stream is defined in the loadable module "clim-postscript". See 1.5, Loading CLIM for details of how to load CLIM and associated modules.

Common Lisp Interface Manager 2.0 User's Guide - 7 Aug 2017