How do you include a hyperlink (URL) in a PDF that links to an external site?
Using a simple string like \"http://www.stackoverflow.com\", a link is automatically ge
For some reasons, the example given didn't work. I used wayback machine and found the following snippet that worked:
<textField hyperlinkType="Reference">
<reportElement x="5" y="95" width="300" height="15"/>
<textFieldExpression class="java.lang.String">" >> Click here to go to www.google.com"</textFieldExpression>
<hyperlinkReferenceExpression>"http://www.google.com
</hyperlinkReferenceExpression>
</textField>
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.
For example:
<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>
The hyperlinkTarget attribute behaves in the same way as the target attribute in HTML.
Note that only textFields, images, and charts can be hyperlinked in this way.