[cl-typesetting-devel] Non-macro interface to building documents.

David J Cooper Jr david.cooper at genworks.com
Tue Feb 10 22:54:51 UTC 2004


Hi Erik,

Assuming you have a list of objects in the variable "objects," try
something like this:

...
(typeset:table ()
 (dolist (object objects)
   (typeset:row ()
     (typest:cell () (typeset:paragraph () (typeset:put-string (slot-value object 'name))))
     (typest:cell () (typeset:paragraph () (typeset:put-string (slot-value object 'telephone))))
     (typest:cell () (typeset:paragraph () (typeset:put-string (slot-value object 'age)))))))
...

 -dave

Erik Enge writes:
 > I have a list of objects.  Each object has three slots: name, 
 > telephone, age.  I'd like to make
 > a PDF document that displays this information in neat tables.  The only 
 > thing I don't know is
 > how many objects there are in my list.
 > 
 > (defun testpdf (&optional (file #P"/tmp/test.pdf"))
 >    (pdf:with-document ()
 >      (pdf:with-page ()
 >        (pdf:with-outline-level ("Example" (pdf:register-page-reference))
 > 	(pdf:set-line-width 0.1)
 > 	(let ((content
 > 	       (typeset::compile-text ()
 >                   (typeset:paragraph (:font "Helvetica-Bold" :font-size 
 > 16)
 >                     "Test document")
 >                   (typeset:hrule :dy 2)
 >                   (typeset:table (:col-widths '(100 430) :border 0)
 >                     (typeset:row ()
 >                       (typeset:cell ()
 >                         (typeset:paragraph ()
 >                           "Name"))
 >                       (typeset:cell ()
 >                         (typeset:paragraph ()
 >                           "Erik Enge")))
 >                     (typeset:row ()
 >                       (typeset:cell ()
 >                         (typeset:paragraph ()
 >                           "Telephone"))
 >                       (typeset:cell ()
 >                         (typeset:paragraph ()
 >                           "555-1234")))
 >                     (typeset:row ()
 >                       (typeset:cell ()
 >                         (typeset:paragraph ()
 >                           "Age"))
 >                       (typeset:cell ()
 >                         (typeset:paragraph ()
 >                           "25")))))))
 >            (typeset::draw-block content 20 800 545 700 0))))
 >      (pdf:write-document file)))
 > 
 > Can someone show me how I would turn that code into code that would 
 > essentially do the
 > same thing for a list of objects, as described at the top of the mail?  
 > I have read typo.lisp
 > and tables.lisp but there doesn't seem to be a functional equivalent to 
 > the table macro.
 > 
 > Thanks in advance,
 > 
 > Erik.
 > 
 > 
 > _______________________________________________
 > cl-typesetting-devel site list
 > cl-typesetting-devel at common-lisp.net
 > http://common-lisp.net/mailman/listinfo/cl-typesetting-devel
 > 
 > 





More information about the cl-typesetting-devel mailing list