[reportlab-users] I would like to click on the table of contents entries and jump immediately to the correct page

jo etaoinbe at yahoo.com
Wed Jan 6 05:25:19 EST 2010




Hi all,



>

>I have used multibuild to create a table of contents. I would like to click on the table of contents entries and jump immediately to the correct page. How should I change the class below to achieve this?

>

>Thanks

>Joe

>

>

>

>class MyDocTemplate(BaseDocTemplate):

>#class MyDocTemplate(SimpleDocTemplate):

> def __init__(self, filename, **kw):

> self.allowSplitting = 0

> #apply(SimpleDocTemplate.__init__, (self, filename), kw)

> apply(BaseDocTemplate.__init__, (self, filename), kw)

> frameT=[Frame(2.5*cm, 2.5*cm, 15*cm, 25*cm, id='F1')]

> #template = PageTemplate('normal', [Frame(2.5*cm, 2.5*cm, 15*cm, 25*cm, id='F1')])

> self.addPageTemplates([PageTemplate(id='normal',frames=frameT, onPage=myFirstPage),

> PageTemplate(id='myLaterPages',frames=frameT, onPage=myLaterPages) ])

>

> #self.addPageTemplates(template)

>

> def afterFlowable(self, flowable):

> "Registers TOC entries."

> if flowable.__class__.__name__ == 'Paragraph':

> text = flowable.getPlainText()

> style = flowable.style.name

> if style == 'Heading1':

> self.notify('TOCEntry', (0, text, self.page))

> if style == 'Heading2':

> self.notify('TOCEntry', (1, text, self.page))

Regards,

Joe



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20100106/df3a2df8/attachment.html>


More information about the reportlab-users mailing list