[cl-typesetting-devel] multi-page documents

Peter Seibel peter at javamonkey.com
Mon Jan 19 22:09:32 UTC 2004


"Marc Battyani" <marc.battyani at fractalconcept.com> writes:

> "Peter Seibel" <peter at javamonkey.com> wrote:
> >
> > 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.
> >
> 
> Here it is. I will add it to test.lisp.
> 
> (defun muli-page-hello (&optional (file #P"/tmp/hello.pdf"))
>   (pdf:with-document ()
>     (let ((content
>     (compile-text ()
>   (vspace 100)
>   (paragraph (:h-align :centered :font "Helvetica-Bold" :font-size 50 :color
> '(0.0 0 0.8))
>       "cl-typesetting" :eol
>       (vspace 2)
>       (hrule :dy 1)
>       (with-style (:font "Times-Italic" :font-size 26)
>         "The cool Common Lisp typesetting system")
>       (vspace 50)
>         (dotimes (i 100)
>           (with-style (:font "Helvetica-Oblique" :font-size 36 :color '(0.0
> 0 0.8))
>      "Hello World!" :eol))))))
>       (loop while (boxes content) do
>      (pdf:with-page ()
>        (pdf:set-line-width 0.1)
>        (draw-block content 20 800 545 700 0))))
>     (pdf:write-document file)))

Cool. Thanks. That got me going. One oddity I noticed, at least when
viewing these docs with xpdf on GNU/Linux: if a paragraph gets broken
across a page, the text on the second page isn't colored. Any idea
what's up with that?

<time passes>

On a probably related note, check out my first crack at typesetting my
book with cl-typesetting.

  <http://www.gigamonkeys.com/book/chap1.pdf>

Notice how the beginning of each page loses it's formatting. The code
that generates this is at:

  <http://www.gigamonkeys.com/book/my-typeset.lisp>

The problem seems to be related to the way I'm adding the header in
draw-page. Poking around a bit I came up with theory that the
make-filled-vbox function is grabbing boxes from the main contents but
if the styles switch in the middle of a paragraph (as they do here
because of the header) they don't get put back when the lines
containing the rest of the paragraph are emitted. Of course that could
be totally wrong--just a guess really.

Anyway, if there's some better way to add a header, please let me
know.

-Peter

-- 
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