[cl-typesetting-devel] Page n of m?
Bob Hutchison
hutch at recursive.ca
Thu Sep 30 21:43:40 UTC 2004
On Sep 30, 2004, at 5:20 PM, Marc Battyani wrote:
> Bob Hutchison wrote:
>>>
>>
>> I am getting current pass: 1, undefined references: NIL,
>> changed-references: NIL
>
> This is not good.
> When the ref id is not yet defined, #'find-ref-point-page-number
> should push
> the missing ref id in *undefined-references*.
> This would start a second pass.
>
> Are you looking at the value of *undefined-references* just before the
> end
> of with-document ?
> (it's cleared at the beginning)
>
> Marc
>
It seems that I was calling the mark-ref-point too soon (i.e. before
the footer was built). I've appended the code I am using (it is based
on the multi-page example in test.lisp). I added some format statements
to some methods in references.lisp and this is what I'm getting. I also
changed the initform of pagenumber to -1 from 999 so I could see the
difference between the reference point not being defined and the
initform. It seems that the page number is not being changed.
find-ref-point 'END-OF-DOC' -- ref-point [NIL]/NIL/NIL
find-ref-point-page-number UNKNOWN ;; this means that there is no
ref-point yet
find-ref-point 'END-OF-DOC' -- ref-point [#<TYPESET::REF-POINT
12D4BD43>]/#<TYPESET::REF-POINT 12D4BD43>/NIL
find-ref-point-page-number -1 ;; now there is one, but the page number
is -1 (the initform)
current pass: 1, undefined references: (END-OF-DOC),
changed-references: NIL
find-ref-point 'END-OF-DOC' -- ref-point [#<TYPESET::REF-POINT
12D4BD43>]/NIL/#<TYPESET::REF-POINT 12D4BD43>
find-ref-point-page-number -1
find-ref-point 'END-OF-DOC' -- ref-point [#<TYPESET::REF-POINT
11DCA83B>]/#<TYPESET::REF-POINT 11DCA83B>/#<TYPESET::REF-POINT
12D4BD43>
find-ref-point-page-number -1
current pass: 2, undefined references: NIL, changed-references: NIL
WRITE THE DOCUMENT NOW
And the code...
(defun page-n-of-m (&optional (file #P"/tmp/page-n-of-m.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)
(declare (ignore second))
(format nil "Printed on ~4D-~2,'0D-~2,'0D
~2,'0D:~2,'0D"
year month date hour minute)))
(header (compile-text ()
(paragraph (:h-align :center
:font "Helvetica-BoldOblique"
:font-size 12)
"Multi-page example document")
(hrule :dy 1/2)))
(footer (lambda (pdf:*page*)
(compile-text (:font "Helvetica" :font-size 10)
(hrule :dy 1/2)
(hbox (:align :center :adjustable-p t)
(verbatim print-stamp)
:hfill
(verbatim
(format nil "Page ~d of ~d" pdf:*page-number*
(tt::find-ref-point-page-number :end-of-doc))))))))
(setq content
(compile-text ()
(paragraph (:font "Times-Bold" :font-size 16 :top-margin
20)
"2. Second paragraph group"
(hrule :dy 2))
(dotimes (i 40)
(paragraph (:font "Times-Roman" :font-size (+ 6 (random
10)))
(verbatim (format nil "2.~d. " (1+ i)))
(dotimes (j (1+ (random 5)))
(put-string "The quick brown fox jumps over the
lazy dog. "))))
;(tt::mark-ref-point :end-of-doc) <-- This won't work
here
))
(draw-pages content :margins margins :header header :footer
footer))
(tt::mark-ref-point :end-of-doc)
(when pdf:*page* (finalize-page pdf:*page*))
(format t "current pass: ~A, undefined references: ~A,
changed-references: ~A~%" tt::*current-pass* tt::*undefined-references*
tt::*changed-references*)
(when (typeset::final-pass-p)
(format t "WRITE THE DOCUMENT NOW~%")
(pdf:write-document file))))
More information about the cl-typesetting-devel
mailing list