From peter at javamonkey.com Mon Jan 19 16:30:38 2004 From: peter at javamonkey.com (Peter Seibel) Date: Mon, 19 Jan 2004 16:30:38 -0000 Subject: [cl-typesetting-devel] multi-page documents In-Reply-To: <20031220155903.GA16626@w-m-p.com> References: <16355.37938.71979.988062@mccarthy.genworks.com> <20031220155903.GA16626@w-m-p.com> Message-ID: Klaus Weidner 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 From marc.battyani at fractalconcept.com Mon Jan 19 17:09:46 2004 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Mon, 19 Jan 2004 18:09:46 +0100 Subject: [cl-typesetting-devel] multi-page documents References: <16355.37938.71979.988062@mccarthy.genworks.com><20031220155903.GA16626@w-m-p.com> Message-ID: <1c3c01c3deaf$0bb525d0$0303a8c0@marc2> "Peter Seibel" 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))) > > 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. I don't have other examples. I use cl-typesetting in production applications but the documents generated are embedded in these apps. I can't easily extract them, and they would be mostly boring ;-) Nothing fancy. So let's make a call for examples. If anybody has some examples to share please post them to this list. Marc From peter at javamonkey.com Mon Jan 19 22:09:32 2004 From: peter at javamonkey.com (Peter Seibel) Date: Mon, 19 Jan 2004 22:09:32 -0000 Subject: [cl-typesetting-devel] multi-page documents In-Reply-To: <1c3c01c3deaf$0bb525d0$0303a8c0@marc2> References: <16355.37938.71979.988062@mccarthy.genworks.com> <20031220155903.GA16626@w-m-p.com> <1c3c01c3deaf$0bb525d0$0303a8c0@marc2> Message-ID: "Marc Battyani" writes: > "Peter Seibel" 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?