Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23305

How to add a link to an object in a PDF using reportlab?

$
0
0

I am trying to make an infographic and I want to add social media links to it. I started off with reportlab, since this module supposedly can add links to output pdf files, but I can't get it work. I am not engaded with reportlab, so any other working library is ok, as long as I can create a PDF with it with clickable hyperlinks.

#  SOCIAL LINKSlink_url = 'https://www.facebook.com/'link_rect = (100, 100, 200, 120)# Draw a yellow rectangle over the linked areapdf_canvas.setFillColorRGB(1, 1, 0)  # Set the fill color to yellow (RGB: 1, 1, 0)pdf_canvas.rect(*link_rect, fill=1)  # Draw the rectangle# Create a clickable hyperlinkpdf_canvas.linkURL(link_url, link_rect, relative=1)#  PDF SAVEpdf_canvas.save()

Reportlab is properly imported, I don't get any error message, the code runs and the PDF is generated. The yellow rectangle (which I added just to see where the link is supposed to be) is there, only there is no clickable hyperlink.

I tried to solve this with AI (Codeium - I code in VS Code), but it ran out of ideas.


Viewing all articles
Browse latest Browse all 23305

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>