Lisp HUG Maillist Archive

Printing in CAPI


I have a CAPI app written, and I'm having some trouble getting it to
print.  I have a postscript printer configured and it prints a Lispworks
test page.

I'm only printing text but I'd like to use a couple different size fonts
to make the outline format more attractive.  Code follows- yes it is a
grocery list program... but nevertheless...



(defun print-grocerylist (intf)
  
  (let ((ptrsel  (print-dialog :owner intf :print-selection-p nil :print-copies-p nil :print-pages-p nil)))

    (when ptrsel

      (with-print-job (gport :printer ptrsel)
        (multiple-value-bind (pagewidth pageheight) (get-page-area ptrsel)
          
          (let* ((drawrect         (multiple-value-bind (left top right bottom) 
                                       (get-bounds (gm-grocerylist-panel intf))
                                     (list left top right bottom)))

                 (drawwidth        (rectangle-width drawrect))
		 (drawheight       (rectangle-height drawrect))

		 (widen-p          (> (/ pagewidth pageheight)
                                      (/ drawwidth drawheight)))

		 (page-transform-x 0)
		 (page-transform-y 0)
		 (page-transform-width    (if widen-p
					      (* pagewidth (/ drawheight pageheight))
					    drawwidth))

		 (page-transform-height   (if widen-p
					      drawheight
					    (* pageheight (/ drawwidth pagewidth)))) )



	    (let* ((glist-vector     (collection-items     (gm-grocerylist-panel intf)))
		   
		   (fdesc-big        (make-font-description :family "NewCenturySchlbk-Bold" ) )
		   (fdesc-med        (make-font-description :family "Helvetica") )
		   (fdesc-little     (make-font-description :family "Courier") )

		   (bigfontlist      (find-matching-fonts gport fdesc-big))
		   (medfontlist      (find-matching-fonts gport fdesc-med))
		   (littlefontlist   (find-matching-fonts gport fdesc-little)) )


I was under the impression that a printer graphics port could be drawn
into just like a regular one, but the 'find-matching-fonts' throw the
error;


No applicable methods for #<standard-generic-function
graphics-ports::%find-matching-fonts 20CEBB6A> 
with args (#S(capi-postscript-library::postscript-printer-description 
     capi-postscript-library::keywords #<equal Hash Table{24} 21735924> 
     capi-postscript-library::code #<equal Hash Table{17} 21735814>
     capi-postscript-library::order #<equal Hash Table{3} 21735704> 
     capi-postscript-library::ui-elements (("*PageSize" :pick-one "A4" 
						       "Page Size" # # # # # # #) 
						       ("*InputSlot" :pick-one "Cassette" "Paper Source" #)
						       ("*ManualFeed" :boolean "False" "Manual Feed" # #)) 
     capi-postscript-library::ui-constraints #<equal Hash Table{0} 217355F4> 
     capi-postscript-library::installable-options nil 
						  capi-postscript-library::fonts nil) 
     (:family "NewCenturySchlbk-Bold"))


I've tried variations where I pass in :pane to with-print-job, but no
headway yet.  I think I'm missing something about how the printer work
and was hoping someone on the list might be able to help.

I'm using Lispworks 4.3.7 on x86 Linux.

Thanks,

Greg


Updated at: 2020-12-10 08:48 UTC