ryofenk Posted October 3, 2019 Share Posted October 3, 2019 Hello everyone,Just a simple question about hyperlinks, hoping it hasn't been asked already. I am making a report with Jasper Studio 6.9.0 and I want to make a hyperlink within a text field wth only some words redirecting to the site, not the whole text field. Is it possible, if not are there any workarounds?Thanks in advance! Link to comment Share on other sites More sharing options...
C-Box Posted October 3, 2019 Share Posted October 3, 2019 You coud use the normal href anchor syntax for html hyperlinks (<a href ....> </a> ) within your whole text for certain passages. Then you set the TextFieldProperty Markup to HTML, so that the enginge just renders the link text and not the html-tags + URL. Should work (but not in default (ireport)viewer when I remember right, just in Html/PDF outout, when I remember right)hth + regardsC-Box Link to comment Share on other sites More sharing options...
ryofenk Posted October 3, 2019 Author Share Posted October 3, 2019 Thank you for your reply, I tried to do that, but it seems like the tag is not recognized at all when generating the report. I only get the text with no hyperlink at all. I did switch the markup to html from the TextField properties but nothing seems to work. Did I miss something? I did not really get the last bit of your answer either, do you mean that it won't render in the preview but only in the actual PDF output?The link does work if I put the actual address in a static text, but not when trying to hyperlink it within a TextField. Link to comment Share on other sites More sharing options...
C-Box Posted October 3, 2019 Share Posted October 3, 2019 Well I just created a sample 4 u just with a simple static parameter and a link within the text (it's either if parameter or fields. both handle dynamic content)<?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="TestURL" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0c81e6db-3b5f-4d36-a45c-f33d0da5643e"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <parameter name="parameter1" class="java.lang.String"> <defaultValueExpression><![CDATA["This is a Test for <a href=http://wiki.selfhtml.org/wiki/href">The Link within </a> the Text]]></defaultValueExpression> </parameter> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"> <textField> <reportElement x="0" y="21" width="555" height="45" uuid="c4db0c7d-3c14-4f1a-9da1-aa3e6f33dc1f"/> <textElement markup="html"/> <textFieldExpression><![CDATA[$P{parameter1}]]></textFieldExpression> </textField> </band> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="61" splitType="Stretch"/> </columnHeader> <detail> <band height="125" splitType="Stretch"/> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="54" splitType="Stretch"/> </pageFooter> <summary> <band height="42" splitType="Stretch"/> </summary></jasperReport>[/code]When you export this to PDF, you can click onto the words "The Link within" ... or also see the mouse pointer changing to hand cursor:The built-in Preview-Module in iReport can't handle these "inline" links within a text, as this doesn't implement the correct hyperlink listener methods. Not sure whether the JasperSoftStudio Preview will do that also. But as you see, the PDF-Exporter (and also the html-exporter do handle that correctly) So perhaps this helps you a bit. If you wan't to color the inline link , you also can use the font-color html tags for that purpose.regardsC-Box Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now