[cl-typesetting-devel] Problem with draw-block

Marc Battyani marc.battyani at fractalconcept.com
Wed Nov 7 15:24:04 UTC 2012


On 7/11/12 24:54 , David Creelman wrote:
> Hi,
> I'm trying to print out some content that I've defined in the usual compile-text way, but
> via draw-block rather than via draw-pages. I'm wanting to use draw-block because it has
> a :rotate key which I'm wanting to use.
>
> Below is first-doc2 using draw-pages which works and a very similar demo first-doc using 
> draw-block that doesn't ?
>
> (defun first-doc2 (&key (file "/tmp/first-doc.pdf"))
>   (tt:with-document ()
>     (let ((content (tt:compile-text ()
> 		     (tt:paragraph () "Generated with Cl-Pdf and Cl-typesetting"))))
>       (tt:draw-pages content)
>       (when pdf:*page* (typeset:finalize-page pdf:*page*))
>       (tt:write-document file))))
>
> (defun first-doc (&key (file "/tmp/first-doc.pdf"))
>   (tt:with-document   ()
>
>     (let ((content (tt:compile-text ()
> 		     (tt:paragraph ()  "Some demo text"  ))))
>
>       (tt::draw-block content 10 10 300 300)
>       (when pdf:*page* (typeset:finalize-page pdf:*page*))
>       (tt:write-document file))))
>
> The astute reader will note that the first-doc2 is a verbatim copy of the example code in
> cl-pdf-doc.pdf (comes in with cl-typesetting via quicklisp).
>
> I kind of thought that draw-block would work in the same way as draw-pages, but it obviously
> needs more. 
draw-block needs a page to write on.

(defun first-doc (&key (file "~/doc1.pdf"))
  (tt:with-document   ()
    (let ((content (tt:compile-text () (tt:paragraph ()  "Some demo
text"  ))))
      (pdf:with-page ()
        (tt::draw-block content 10 700 300 300))
      (when pdf:*page* (typeset:finalize-page pdf:*page*))
      (tt:write-document file))))

BTW the coordinates origin is the bottom left of the page so 10 is too
small for y and I've put 700 instead.

Marc




More information about the cl-typesetting-devel mailing list