[cl-typesetting-devel] Page n of m?

Peter Seibel peter at javamonkey.com
Thu Sep 30 21:30:55 UTC 2004


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

> Peter Seibel wrote:
>> "Marc Battyani" <marc.battyani at fractalconcept.com> writes:
>>
>> > Hum, you should follow more closely the evolution of cl-typesetting
>> > ;-) What you want is called references and it's in references.lisp.
>>
>> Great! Next you're going to tell me you've already got a mechanism for
>> doing footnotes.
>>
>> Hmmmm. Not quite. I did what you said but it thinks my document is 999
>> pages long. Here's the main bit of my code. Maybe I've just made some
>> dumb mistake that you can point out:
>
> The multipass mechnism is integrated into typeset:with-document so it should
> work in your code.
>
> As they are several passes you should use:
>
>  (when (typeset::final-pass-p)
>    (pdf:write-document file))
>
> To avoid writing the pdf file during the intermediate passes.
> (I will probably redefine write-document in typeset to handle this more
> easily.)
>
> How many passes go you get ? What are the values of *current-pass*
> *undefined-references* *changed-references* ?

Okay, I added some calls to this function:

  (defun show-refs () 
    (format 
      t "*current-pass*: ~a; *undefined-references*: ~a; *changed-references*: ~a; *max-number-of-passes*: ~a~%" 
      typeset::*current-pass* typeset::*undefined-references* typeset::*changed-references*
      typeset::*max-number-of-passes*))

as shown here:

  (defun sexp->pdf (paragraphs &optional (file #P"/tmp/hello.pdf"))
    (let ((*note-counter* 0)
          (*notes* nil))
      (typeset:with-document ()
        (let ((content
               (typeset::compile-text ()
                 (let ((*my-leading-ratio* 2.0))
                   (dolist (p paragraphs) (emit-pdf p)))
                 (typeset::vspace 24)
                 (typeset::hrule :dy .1)
                 (typeset::vspace 6)
                 (let ((*default-font-size* 10))
                   (loop for n in (nreverse *notes*)
                         for counter from 1
                         do (emit-note counter n)))
                 (typeset:mark-ref-point :the-end))))
          (loop
             for header = (typeset::compile-text ()
                            (typeset::paragraph
                                (:h-align :right :font "Times-Italic" :font-size 10)
                              (typeset::put-string (format nil "~a~c~d of ~d" (second (first paragraphs)) +mdash+ pdf:*page-number* (typeset:find-ref-point-page-number :the-end))) :eol
                              (typeset::put-string (format nil "Copyright ~c 2003-2004, Peter Seibel." +copyright+)) :eol
                              (typeset::put-string (date-string)) :eol))
             while (typeset::boxes content)
             do (draw-page content header :width 612 :height 792 :margins '(72 36 72 72) :header-height (- 108 36))
               (show-refs)))
        (show-refs)
        (pdf:write-document file)))
    (truename file))

and got this:

  CL-USER> (typeset-book "text/allegroserve.txt")
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  *current-pass*: 1; *undefined-references*: NIL; *changed-references*: NIL; *max-number-of-passes*: 2
  Chapter practical-web-programming-with-allegroserve: /home/peter/www.gigamonkeys.com/book/practical-web-programming-with-allegroserve.pdf
  NIL

-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