[reportlab-users] Trying to implement "See page X"
Robin Becker
robin at reportlab.com
Thu Jun 4 05:15:07 EDT 2009
Roberto Alsina wrote:
> And it's almost there, but I am doing something wrong :-)
>
> Here's my approach: In some cases, instead of a regular paragraph, create a
> DelayedParagraph wrapper around Paragraph, which is an IndexingFlowable and
> gets notified of bookmarks.
>
> Then, in DelayedParagraph.notify, "fix" the text by replacing references to
> bookmarks with the corresponding page numbers.
>
> Example:
>
> 'Go see A title (Page %(a-title)s)'%{'a-title': 2}
>
> And it works like a charm... unless the bookmark is *after* the
> DelayedParagraph, in which case it just gets drawn before the text is "fixed".
>
> I though that by returning False to isSatisfied(), the delayedParagraph would
> not get drawn, then force another build pass, fix the references, then draw
> it, but I am obviously mistaking.
>
> I can't use onDraw like the table of contents does because I need to put the
> page number in the paragraph textflow, and that means I can't just "save the
> space" for it.
>
> Sadly since this is in rst2pdf extracting a small example is not trivial, I
> hope my description is useful...
>
> Here is my DelayedParagraph class:
>
> http://pastebin.com/f60b5f7e9
>
In general there's no obvious way to do both forward and backward links single pass
However, it should be possible to do this with multi-pass without any delay at
all. What's required is that the variables that are being referenced in the draw
method have stabilized. Are you using multibuild?
--
Robin Becker
More information about the reportlab-users
mailing list