我正在使用 ReportLab 使用 Python 制作 pdf。我想向画布添加一个形状,并让该形状充当超链接。使以下示例中的矩形链接到 google.com 的最简单方法是什么?
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
c = canvas.Canvas("hello.pdf")
# move the origin up and to the left, draw square
c.translate(inch,9*inch)
# How do I make this rectangle link to google.com?
c.rect(inch,inch,1*inch,1*inch, fill=1)
c.showPage()
c.save()
Call linkURL
在画布上:
c.linkURL('http://google.com', (inch, inch, 2*inch, 2*inch), relative=1)
该矩形是可点击区域,因此您必须将其与绘制的矩形相匹配。参数是两个坐标,两次x, y
对于左下角和右上角。
请参阅此博文中的更多示例:http://www.hoboes.com/Mimsy/hacks/adding-links-to-pdf/ http://www.hoboes.com/Mimsy/hacks/adding-links-to-pdf/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)