[reportlab-users] Trying to implement "See page X"
Roberto Alsina
ralsina at netmanagers.com.ar
Wed Jun 3 14:27:42 EDT 2009
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
--
("\''/").__..-''"`-. . Roberto Alsina
`9_ 9 ) `-. ( ).`-._.`) KDE Developer (MFCH)
(_Y_.)' ._ ) `._`. " -.-' http://lateral.netmanagers.com.ar
_..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia
(l)-'' ((i).' ((!.' according to alexa.com (27/5/2007)
"Our opponent is an alien starship packed with atomic bombs, I said.
We have a protractor. Okay, I’ll go home and see if I can scrounge up a
ruler and a piece of string." — Neal Stephenson
More information about the reportlab-users
mailing list