CLIM mail archive


printing in CLIM - summary

Thanks to all that replied to my request.  I must say that I am *very*
impressed by clim's abilities to print.  Boy, what a difference with
other systems!!!  That's what I call a well tought, easy to use and
reliable way to do things.  I had *no* problem.

If someone wants to create a clim FAQ, this can be inserted in it.

Here is the original request:

     I'd like to print the content of what has been accumulated in a stream
     (part of a pane of a frame).
     When the content is only text, it's easy, I just do:
       (com-print-history :name t :menu t)
       (with-open-file (output-file "nanesse:to-print;history.text"
			     :direction :output
			     :if-exists :new-version)
	   (frame-standard-output clim:*application-frame*) output-file))
       (cp:execute-command "hardcopy file" "nanesse:to-print;history.text"))
     But when it's general clim drawing functions, I guess I must use
     with-output-to-postscript-stream and somehow replay the history of my
     pane (from the parent output-record, right?) in the new postscript
     Does someone have a nice and easy example of this to help me out?


Here are the replies (I think they are all useful in understanding the problem):

Date: Mon, 14 Dec 92 18:48:33 +0100
From: Oliver Christ <>
Message-Id: <>
Received: by
	id AA00441; Mon, 14 Dec 92 18:48:33 +0100
In-Reply-To: Vincent Keunen's message of Mon, 14 Dec 1992 17:33+0200 <>
Subject: printing a clim stream

Hi Vincent,

I have been using something like

    (with-open-file (psfile <<<filename>>> :direction :output :if-exists :supersede)
      (clim:with-output-to-postscript-stream (stream psfile :multi-page t)
        (clim:replay (slot-value (clim:get-frame-pane clim:*application-frame* 

but it isn't as nice as redoing the whole output (call a redisplay function)
with output to PostScript. 



Date: Mon, 14 Dec 1992 13:57-0500
From: Scott McKay <SWM@STONY-BROOK.SCRC.Symbolics.COM>
Subject: printing a clim stream
To: nrb!keunen,
In-Reply-To: <>
Message-Id: <19921214185711.9.SWM@SUMMER.SCRC.Symbolics.COM>

There is no such "nice and easy example", because it is not nice and
easy.  Moving output records from one display device to another is not
easy because text and graphics can have different sizes on different
output devices.  Thus, using FORMATTING-TABLE on some window to format a
table full of text can produce output records that no good for some
postscript printer, because the alignment is all wrong.

The only way to reliably get good output for multiple display devices is
to generate it freshly for each display device.

Date: Mon, 14 Dec 1992 14:54-0500
From: Mark Nahabedian <naha@RIVERSIDE.SCRC.Symbolics.COM>
Subject: printing a clim stream
To: nrb!keunen,,
In-Reply-To: <>
Message-Id: <19921214195452.5.NAHA@LILIKOI.SCRC.Symbolics.COM>

Actually what you should do is re-execute the code which did the
drawing, this time doing the output to a PostScript stream instead of to
the window where you drew it before.  Output histories are specific to
the window they were created for and should not be used in conjunction
with a different output stream.

Date: Mon, 14 Dec 1992 17:28:36 -0700
From: Brent Reeves <>
Message-Id: <>
To: nrb!keunen
In-Reply-To: Vincent Keunen's message of 14 Dec 1992 17:33+0200
Subject: printing a clim stream

 since the draw-work-area (below, in the com-ps command) function
 takes a stream as input, it is easy to redirect this stream to
 the postscript stream.  Notice in this command there is
 strangeness going on... after I create the postscript stream, I
 read it back in and delete a "setrgbcolor" line.  This oughtn't
 have to be done, but for me [Genera 8.1 CLIM 1.1] it is the only
 way I can get it to work.  Also, I print the file from a UNIX
 box; "hardcopy file" does not work.  Others have not trouble
 with postscript and "hardcopy file", so it may work fine like in
 your example above.

(define-indy-command (com-ps :name t :menu nil)
  ((scale 'float))
    :direction :output)
    (stream file-stream
	    :multi-page t)
    (with-scaling (stream scale scale)
		  (draw-work-area *af* stream))))
  ;; now remove the offending " 1.00 1.00 1.00 setrgbcolor" line
  (let ((eof '|EOF|)
      :direction :input)
       :direction :output)
      (block exit
	     (loop do
		      (line nil)
		      (read-line input nil eof))
		      (equal line eof)
		      (return-from exit nil))
		      (string-equal " 1.00 1.00 1.00 setrgbcolor" line)
		      (format output "~&~a" line))))))))
  (audit "~&Postscript file is

And here is the code I now use to print:

The code inside clim:with-output-to-postscript-stream is exactly the
code used to draw the map on the screen.  Note that the last form is
only valid on Genera machine.

(defun print-network-map ()
  (let ((frame (nanesse-frame)))
    (with-open-file (the-file "nanesse:to-print;"
			      :direction :output
			      :if-exists :new-version)
      (clim:with-output-to-postscript-stream (stream the-file :multi-page t)
	(vk-1dessine-villes0 stream)
	(1initialise-coordonnees-noeuds0 (noeuds-a-afficher frame))
	(ansi-loop::loop for one-node in (noeuds-a-afficher frame)
	  (clim:present one-node
			  :up-or-down ,(up-or-down one-node)
			  :selected ,(selected one-node))
			;;(clos:class-name (clos:class-of one-node))
			:view clim:+iconic-view+ :single-box t
			:stream stream)))))
  (cp:execute-command "hardcopy file"

Thanks all for your help.  Hope this summary is useful.

Never trust a pretty header: use to reply
Keunen Vincent                  Network Research Belgium
R&D, Software Engineer          Parc Industriel des Hauts-Sarts                   2e Avenue, 65
tel: +32 41 407282              B-4040 Herstal
fax: +32 41 481170              Belgium

Main Index | Thread Index