[英]Inserting hyperlinks into pdf generated with pisa
Currently I am generating a pdf from a html template in django/python. 目前,我正在从django / python中的html模板生成pdf。
Here is a relevant snipit from my view 我认为这是一个相关的小故事
result = StringIO.StringIO()
html = render_to_string(template='some_ref/pdf.html', { dictionary passed to template},)
pdf = pisa.pisaDocument(StringIO.StringIO(html), dest=result)
return HttpResponse(result.getvalue(), content_type='application/pdf')
And my template is an html file that I would like to insert a hyperlink into. 我的模板是一个HTML文件,我想在其中插入超链接。 Something like
就像是
<td style="padding-left: 5px;">
<a href="/something_here/?referral_type={{ template_variable }}">{{ some_other_variable }}</a>
</td>
Actually, the pdf generates fine and the template variables are passed correctly and show in the pdf. 实际上,pdf可以很好地生成,并且模板变量可以正确传递并显示在pdf中。 What is inside the
a
tag is highlighted in blue and underlined as if you could click on it, but when I try to click on it, the link is not followed. 标签内的内容以蓝色突出显示,并
a
下划线,就像您可以单击它一样,但是当我尝试单击它时,未遵循该链接。 I have seen pdfs before with clickable links, so I believe it can be done. 我以前看过带有可点击链接的pdf,所以我相信可以做到。
Is there a way I can do this to make clickable hyperlinks on my pdf using pisa? 有没有办法我可以使用比萨在pdf上创建可点击的超链接?
它适用于完整的url:http协议和域
<a href="http://127.0.0.1:8000/something_here/?referral_type={{ template_variable }}">{{ some_other_variable }}</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.