[reportlab-users] how to call bookmarks from external links

Tobias Greitzke tobias.greitzke at togis.com
Thu Jan 21 07:09:52 EST 2021


Hi,

I'm generating a pdf as part of an online documentation. Users should be 
able to click on a link on the webpage that refers to a specific 
endpoint in the generated pdf. Both, the webpage and the pdf are 
generated from data, so I don't know on which page the 
flowables/bookmarks are located within the pdf.

So far I created bookmarks for each endpoint:

title = flowable.text
key = str('s%s' %flowable.text)  # here I use the database Id of the 
object I want to link to

canvas.bookmarkPage(key)
canvas.addOutlineEntry(title, key, 0, 0)
canvas.showOutline()

In the Outline I get all the bookmarks and I can see links like:
https://www.mysite.com/report.pdf?projectId=41#[{"num":7,"gen":0},{"name":"Fit"}]

"num":7 seems to be the number of the last flowable on the page, but as 
I don't know on which page the flowables will end up when I generate the 
pdf, I can't generate links according to these bookmarks.

Is there a way to generate bookmarks that I can define by my data while 
generating the pdf, so I can also use them in a generated link on the 
webpage?


Thanks for your help,
Tobias


More information about the reportlab-users mailing list