使用JasperReports创建外部URL超链接 [英] Create an external URL hyperlink with JasperReports

查看:873
本文介绍了使用JasperReports创建外部URL超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在链接到外部网站的PDF中包含超链接(URL)?

How do you include a hyperlink (URL) in a PDF that links to an external site?

使用像http://www.stackoverflow.com ,会自动生成一个链接。但是,我如何使用像< a href =http://www.stackoverflow.com>点击此处< / a>

Using a simple string like "http://www.stackoverflow.com", a link is automatically generated. But, how can I use a URL like <a href="http://www.stackoverflow.com">Click here</a>?

如果我使用这个HTML字符串,Jaspers会创建一个链接,但也会显示代码。

If I use this HTML string, Jaspers create a link but also shows the code.

使用JasperReports 4.0.4和iReport 4.5.1。

Using JasperReports 4.0.4 and iReport 4.5.1.

推荐答案

要使textField成为外部URL的超链接,您需要添加属性 hyperlinkType =Reference到元素,并在其中添加< hyperlinkReferenceExpression> 标记。引用表达式是您放置URL的位置。

To make a textField a hyperlink to an external URL, you need to add the attribute hyperlinkType="Reference" to the element, and add a <hyperlinkReferenceExpression> tag within it. The reference expression is where you put the URL.

例如:

<textField hyperlinkType="Reference" hyperlinkTarget="Blank">
    <reportElement x="5" y="5" width="200" height="15"/>
    <textElement/>
    <textFieldExpression class="java.lang.String"><![CDATA["Click Here!"]]></textFieldExpression>
    <hyperlinkReferenceExpression><![CDATA["http://www.google.com"]]></hyperlinkReferenceExpression>
</textField>

hyperlinkTarget 属性的行为方式相同作为HTML中的目标属性。

The hyperlinkTarget attribute behaves in the same way as the target attribute in HTML.

请注意,只有textFields,图像和图表可以通过这种方式进行超链接。

Note that only textFields, images, and charts can be hyperlinked in this way.

这篇关于使用JasperReports创建外部URL超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆