[reportlab-users] Url in index.pdf

andrew mercer andrew at sundayta.com
Fri Feb 18 09:43:27 EST 2005


Hi,

I have just started using reportlab but cannot see how to do the following:

I need to create an index.pdf file listing basic information about a set 
of pdfs. One of the columns in the list will be a link to each pdf for 
each row. The url will be relative to where the index.pdf is created and 
run.

This pdf will be used as an index on a cd to allow users to view each 
pdf by selecting the relevant link on in the 'index.pdf' file.

The output needs to be.

[Header]

[Col1 header] 	[Col2 header] 			[Col3 header] ...

[Col1 data1]	[Col2 url to original pdf1]     [Col3 data1]...
[Col1 data2]	[Col2 url to original pdf2]     [Col3 data2]...
.
.
.


I have already created this using the following code (built on your own 
examples.py code) but have not found how I can make [Col2] an underlined 
hyper link (The visible text needs to be different to the actual link).

     colwidths = (40, 100, 300, 100)
     P1 = Paragraph('''
                   <font face="Helvetica">A long title that sometimes 
may need to wrap within its space on each line</font>''',
                   styleSheet["Normal"])
     ## Will create P1 dynamically with each new title
     data= [['[header]', '[header]', '[header]', '[header]'],
            ['2002', Url to PDF, P1, '14/01/2002']
            ['2003', Url to PDF, P1, '14/01/2003']]
     t1 = Table(data, colwidths, None)
     t1.wrap(PAGE_WIDTH, PAGE_HEIGHT)
     t1.setStyle(TableStyle([('ALIGN',(0,0),(-1,-1),'LEFT'),
                            ('VALIGN',(0,0),(-1,-1),'TOP'),
                            ('FONT',(0,0),(-1,-1),'Helvetica'),
                            ]))

I have found how to add a url to a page at a fixed point with a bouding 
box (from the archive lists). However this I think is too restrictive - 
as I will not know the (x,y) position for the url text for each line on 
the page. Anyway I  been unable to successfully plug that into the code 
above.

Any ideas please.

Thanks Andrew Mercer
-- 



More information about the reportlab-users mailing list