[cl-typesetting-devel] How to make some text flush left and someflush right?
Dmitriy Ivanov
divanov at aha.ru
Thu Jul 20 05:35:43 UTC 2006
Hello Peter,
| Suppose I want to make a header that has a chapter name on the left
| and a page number on the right like this:
|
| +--------------------------------------------------------------+
|> Chapter One p. 1 |
| | |
|> Normal text here blah blah blah. The quick brown fox |
|> jumps over the lazy dog ... |
| | |
|
| In the past I've built a table but that requires knowing the width of
| the page and computing the width of various pieces of text. It seems
| like there ought to be a simple way to say, make a box containing
| "Chapter One" that is sized to it's natural size, another box
| containing nothing that expands to fill available space, and a third
| containing "p. 1", also sized to it's natural size and then lay those
| three boxes out in a horizontal line to get the effect I want. Is
| there any easy way to do that?
I would suggest using a function as the header argument of draw-pages. Here
is an excerpt specifying the footer in such a way.
(defun multi-page (&optional (file (lw:current-pathname "multi-page.pdf"))
&aux content (margins '(72 72 72 50)))
(with-document ()
(let* ((print-stamp (multiple-value-bind (second minute hour date month
year)
(get-decoded-time)
(format nil "Printed on ~4D-~2,'0D-~2,'0D
~2,'0D:~2,'0D"
year month date hour minute)))
(header (typeset::compile-text ()
(typeset::paragraph (:h-align :centered
:font "Helvetica-BoldOblique"
:font-size 12)
"Multi-page example document")
(typeset:hrule :dy 1/2)))
(footer (lambda (pdf:*page*)
(typeset::compile-text (:font "Helvetica" :font-size 10)
(typeset:hrule :dy 1/2)
(typeset::hbox (:align :center :adjustable-p t)
(typeset::verbatim print-stamp)
:hfill
(typeset::verbatim
(format nil "Page ~d" pdf:*page-number*)))))) )
(setq content
(typeset:compile-text ()
(typeset:paragraph (:font "Helvetica-Bold" :font-size 16
:top-margin 20)
"1. First paragraph group")
(typeset:hrule :dy 2)
(dotimes (i 40)
(typeset:paragraph (:font "Helvetica" :font-size (+ 6 (random
10)))
(verbatim (format nil "1.~d. " (1+ i)))
(dotimes (j (1+ (random 5)))
(typeset:put-string "The quick brown fox jumps over the
lazy dog. "))))))
(draw-pages content :margins margins :header header :footer footer
:break :after)
(pdf:write-document file))))
--
Sincerely,
Dmitriy Ivanov
lisp.ystok.ru
More information about the cl-typesetting-devel
mailing list