[cl-typesetting-devel] multi-page documents
Peter Seibel
peter at javamonkey.com
Mon Jan 19 16:30:38 UTC 2004
Klaus Weidner <kw at w-m-p.com> writes:
> On Fri, Dec 19, 2003 at 07:13:38PM -0500, David J Cooper Jr wrote:
> > I am thinking about how to tackle multi-page documents with
> > cl-typesetting but am a bit stuck as to how to get started.
> >
> > Each page needs to end up inside a
> >
> > (pdf:with-page ... )
> >
> > right?
> >
> > So if we have a piece of content (made with
> > typeset::compile-text), we need an intermediate step which
> > figures out how to break that content into multiple pages, right?
>
> Just accumulate the content using compile-text, and then let the
> engine split it into pages for you.
>
> Try something like this:
>
> (defun draw-page (content)
> (let ((x 72)
> (y 720)
> (dx 468)
> (dy 648))
> (pdf:with-page ()
> (pdf:with-saved-state
> (pdf:translate x y)
> (let ((box (make-filled-vbox content dx dy)))
> (when box
> (stroke box 0 0)))))))
>
> ;; ...
>
> (let ((content
> (compile-text
> ()
> (paragraph
> "cl-typesetting" :eol
> (vspace 2)
> (with-style (:font "Times-Italic" :font-size 13)
> "The cool Common Lisp typesetting system"))
> ;; ...
> )))
>
> (pdf:with-document ()
> (while (boxes content)
> (draw-page content))))
> (pdf:write-document file)))
>
So I tried to use this code a while back, filling in the ... as best I
could and didn't have much success at all. Before I go back to banging
my head against it, does anyone have an example of extremely simple
multi-page layout--I'm thinking of something along the lines of, I
have a string containing more text than will fit on a page; what's the
simplest way to get it turned into a multi-page PDF. No fancy
formatting required (or even desired at this point), just text broken
up into pages.
-Peter
P.S. Marc, I know you'd rather code than write docs but a set of
graduated cl-typesetting examples sort of like the ones in cl-pdf
would be a useful starting point for folks like me who like to learn
by grabbing something that works and try tweaking it in various ways.
The current cl-typesetting example, though an impressive demo, has a
bit much going on to be used in that way.
--
Peter Seibel peter at javamonkey.com
Lisp is the red pill. -- John Fraser, comp.lang.lisp
More information about the cl-typesetting-devel
mailing list