[cl-typesetting-devel] Formatting across pages bug not quite dead.
Peter Seibel
peter at javamonkey.com
Tue Feb 24 22:52:12 UTC 2004
Peter Seibel <peter at javamonkey.com> writes:
> "Marc Battyani" <marc.battyani at fractalconcept.com> writes:
>
> > "Peter Seibel" <peter at javamonkey.com> writes:
> >
> > > Hmmm. The formatting across pages bug that we thought was fixed seems
> > > to be back. Check out the top of page 5 in:
> > >
> > > <http://www.gigamonkeys.com/book/another-formatting-bug.pdf>
> > >
> > > If I get a chance I'll try to investigate more but I figured I'd let
> > > you know while it's still somewhat fresh in your mind.
> >
> > I will look at this. Looking at your example, it seems that only 2 pages are
> > affected. Are they different in some way ?
>
> Not from my point of view. The only pattern that I can see (given this
> limited data set) is that in both cases where the formatting is
> broken, the first line on the new page contains character formatting
> that gets broken across the line (i.e. it starts on the first line and
> ends on the second line). On page 3 it's the ":if-exists" which is set
> in Courier and on page 5 it's the "WRITE-CHAR" which is set in
> Courier-Bold. In both cases that same formatting seems to get picked
> up by the beginning of the line.
And that indeed seems to be the pattern as this standalone example shows:
(defun bug (&optional (file #P"/tmp/hello.pdf"))
(let ((width 612)
(height 792)
(margins '(108 36 108 108))
(header-height (- 108 36)))
(pdf:with-document ()
(let ((content (typeset::compile-text
()
(dotimes (i 20)
(typeset::paragraph
(:h-align :left :font "Times-Roman" :font-size 12)
(typeset::vspace 12)
(dotimes (j 20)
(cond
((and (= i 2) (= j 19))
(typeset::put-string
(format nil "~d. " j))
(typeset::with-style (:font "Courier-Bold")
(typeset::put-string "The quick"))
(typeset::put-string " brown fox jumps over the lazy dog. "))
(t
(typeset::put-string
(format nil "~d. The quick brown fox jumps over the lazy dog. " j))))))))))
(loop for page-number from 1
for header = (typeset::compile-text
()
(typeset::paragraph
(:h-align :right :font "Times-Roman" :font-size 12)
(typeset::put-string "HEADER") :eol))
while (typeset::boxes content)
do
(destructuring-bind (left &optional (top left) (right left) (bottom top)) margins
(let ((x left)
(y (- height top))
(dx (- width left right))
(dy (- height top bottom)))
(pdf:with-page (:bounds (vector 0 0 width height))
(pdf:with-saved-state
(typeset::stroke (typeset::make-filled-vbox header dx header-height :top) x y))
(typeset::stroke (typeset::make-filled-vbox content dx (- dy header-height) :top) x (- y header-height)))))))
(pdf:write-document file))))
-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