[cl-pdf-devel] PNG images support code

Dmitri Ivanov divanov at aha.ru
Tue Dec 28 18:28:28 UTC 2004


Hello Marc,

| Nice. Works for me in acrobat.
| I will have some time next week to clean and publish up-to-date
| versions of cl-pdf and cl-typesetting. I have started to add and test
| all the contribs I've got so far.
| The cl-pdf repository is already up-to-date (except for this new stuff
| and a new version of iterate).

The PNG support shoud be accompanied by changes like the following in typeset:

(defclass image-box (soft-box)
  ((file :accessor file :initform nil :initarg :file)
   (pdf-image :accessor pdf-image :initform nil :initarg :pdf-image)))

(defmethod stroke ((box image-box) x y)
  (let ((pdf-image (or (pdf-image box)
                       (setf (pdf-image box) (pdf:make-image (file box))))))
    (pdf:add-images-to-page pdf-image)
    (pdf:draw-image pdf-image x (+ (- y (dy box))(offset box))
                      (dx box)(dy box) 0 t)))

(defun image (&rest args &key inline &allow-other-keys)
  (if inline
      (add-box (apply 'make-instance 'image-box
                     :allow-other-keys t args))
      (let ((hbox (make-instance 'hbox
                    :boxes (list (make-hfill-glue)
                                 (apply 'make-instance 'image-box
                                   :allow-other-keys t args)
                                 (make-hfill-glue))
                    :adjustable-p t)))
 (compute-natural-box-size hbox)
 (add-box hbox))))
--
Sincerely,
Dmitri Ivanov
lisp.ystok.ru




More information about the cl-pdf-devel mailing list