Why does hyperlink in PDF not work on smartphones? - hyperlink

I'm generating PDF reports using Jasper reports and I have hyperlink in generated file that doesn't work on smartphones when I open it using Adobe Acrobat Reader.
Code to create the hyperlink
<textField hyperlinkType="Reference" hyperlinkTarget="Blank">
<reportElement mode="Opaque" x="450" y="80" width="100" height="20" forecolor="#0080FF" uuid="d11cac12-8769-450c-b9e8-f512179f33e3">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER} == 1]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Left">
<font size="10" isUnderline="true"/>
</textElement>
<textFieldExpression><![CDATA["Go"]]></textFieldExpression>
<hyperlinkReferenceExpression><![CDATA["https://www.google.com"]]></hyperlinkReferenceExpression>
</textField>

In Jaspersoft Studio, set the Link Target to ‘self’, it works for me. The Link Type is ‘Reference’.

Related

execute drill down jasper report in pop up JasperReports Server

How to execute drill down sub report as a pop up in the same window?
Now it is drilling down in the same window of JasperReports Server.
Below is the code :
<textField hyperlinkType="ReportExecution">
<reportElement mode="Opaque" x="0" y="0" width="60" height="20" forecolor="#2471D6" uuid="dcbcfbd0-98a4-4c94-a7a5-01ff9bff8db8"/>
<textElement textAlignment="Center" verticalAlignment="Middle"> <font isUnderline="true"/> </textElement>
<textFieldExpression><![CDATA[$V{resourceunique1}]]></textFieldExpressio‌​n> <hyperlinkParameter name="_report">
<hyperlinkParameterExpression><![CDATA["jrepo:/ca_ppm/ReportsCustom/sub‌​Reports/ResourceCapacityGridByProjectReport"]]></hyperlinkParameterExpression>
</textField>
I need pop up in the parameter "_report" can I directly give the javascript inside the "_report" parameters expression. If so, can you please lead me to achieving it
You can open a report in a popup window by filling in the Hyperlink tab in Jaspersoft Studio with these values. Note you need add your server URL:
Link Target: Self
Link Type: Reference
Hyperlink Reference Expression: "javascript:void(window.open("jasperserver-url/flow.html?_flowId=viewReportFlow&reportUnit=/public/Resources/Reports/ca_ppm/ReportsCustom/sub‌​Reports/ResourceCapacityGridByProjectReport&decorate=no'" +","+"\'\'"+","+"\'height=480,width=950,scrollbars=no,resizable=yes,status=no,toolbar=no,menubar=no,location=no\'"+"));"

JasperReports localization: using expression in $R{}

I need to localise field values in my JasperReports report. For example in my sql query I have a Gender field. If it have a value of 1 I would like it to display Male and for 0 Female.
I have the following in a text field in my report
$R{"gender" + $F{GENDER}}
Then in my report.properties file I have
gender1=Male
gender0=Female
But this does not work I get a error when its parsing the statement.
Does any body know how to do this.
You can use str() function instead of using $R{} expression.
Try this expression:
<textFieldExpression><![CDATA[str("gender" + $F{Gender})]]></textFieldExpression>
The sample
The csv datasource (names.csv) file:
Name,Gender
Mikle,1
Lisa,0
John,1
Linda,0
The properties file (genders.properties):
gender1=Male
gender0=Female
The jrxml file:
<?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="genders" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="genders" uuid="1ceeef64-2e53-404a-ae1b-9896b8b749cf">
<queryString>
<![CDATA[]]>
</queryString>
<field name="Name" class="java.lang.String"/>
<field name="Gender" class="java.lang.String"/>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="6b27452c-b5f1-4aa3-a4f2-9ae239ff244c" x="0" y="0" width="106" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="b0fcb296-b20b-4171-803d-639754edbc31" x="106" y="0" width="162" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{Gender}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="587d47c0-3908-464b-852a-3009e98def01" x="268" y="0" width="287" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[str("gender" + $F{Gender})]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
The result will be (via preview in iReport):

Jasper Reports - set hyperlink to open other report and transmit collection type parameter

Can this be done? I have tried but parameter is not transmitted. Only the first selected value appear in generated link and then in the report i am opening when clicking hyperlink, I get null value.
Thanks
jrxml hyperlink code:
<textField hyperlinkType="RemotePage" hyperlinkTarget="Blank">
<reportElement uuid="1e57b233-2612-4956-8808-070dc9bcb2f5" x="548" y="30" width="222" height="17"/>
<textElement textAlignment="Right"><font size="12"/> </textElement>
<textFieldExpression><![CDATA["RawData >> Click Here"]]></textFieldExpression>
<hyperlinkTooltipExpression><![CDATA["Click to view RawData"]]></hyperlinkTooltipExpression>
<hyperlinkParameter name="_report">
<hyperlinkParameterExpression><![CDATA["repo:/Team_Reports/CIR_RawData"]]></hyperlinkParameterExpression>
</hyperlinkParameter>
<hyperlinkParameter name="Project_Sets2">
<hyperlinkParameterExpression><![CDATA[$P{Project_Sets}]]></hyperlinkParameterExpression>
</hyperlinkParameter>
</textField>

Grails Jasper Subreport

I am using grails and I have this Jasper report with a subreport in it.
Having this simple two jasper reports
Note: Only .jrxml is the file extension of the files inside the /web-app/reports
Main Report [main_report][subreport area]
<subreport>
<reportElement x="0" y="0" width="555" height="157"/>
<subreportExpression>
<![CDATA[$P{SUBREPORT_DIR} + "test_report.jasper"]]>
</subreportExpression>
</subreport>
Test report [test_report][title.band]
<staticText>
<reportElement x="203" y="30" width="154" height="34"/>
<textElement/>
<text><![CDATA[Hello World]]></text>
</staticText>
And looking in the view or the gsp file I have this command
<g:jasperReport jasper="main_report"
format="pdf, html"
delimiter=" "/>
When I want to view the report in either PDF of HTML format, the report returns a blank page. Am I missing something to display the main_report properly with a subreport test_report.
You need to:
Make sure the sub-report is compiled (do this in iReport), i.e. there should be a .jasper file for sub report in reports dir.
Set the SUBREPORT_DIR parameter before generating the report, e.g.
params.SUBREPORT_DIR = servletContext.getRealPath('/reports') + "/"
(assuming the compiled subreport is in the <app>/web-app/reports directory, the same as the uncompiled reports).

Hyperlink in jasper reports across subreport

I want to add hyperlinks to my report. The hyperlink set in one report should take me to another subreport. Could you please tell me if this is feasible. If it is could you please provide step by step approach to achieve this?
First, yes, it is feasible.
Second, here are your step-by-step instructions:
Right click on element you want to link from and select
Hyperlink.
Choose Hyperlink target: Blank
Choose Hyperlink type: Reference
In the reference tab, type the url to invoke the
subreport (with parameters). For example, in one of my reports I
call the ReportController servlet to create the subreport, like so:
"./ReportController?reportName=ValidationDetailsChart&reportTitle=Validation%20Details&nParms=3&parmName_1=ORD_NUMBER&parmValue_1=" + $F{ORDER_NUMBER} + "&parmName_2=START_TIME_MS&parmValue_2=&parmName_3=END_TIME_MS&parmValue_3="
Add a tooltip in the Tooltip tab (optional). Note you can reference variable and paramter values in the tooltip.
Note that there are other ways to do this, and your method may vary if you aren't using java and servlets to generate your reports. I would recommend looking at the ireport documentation for further instructions.
I got the solution to my problem. I had no requirement where I had to to pass any value from one subreport to another. So I simply right clicked on the textfield that I wanted the link on. I set the Hyperlink target as "Self" and Hyperlink type as "LocalPage" and in Hyperlink Page expression I set the following expression : Integer.valueOf(i) ,where i is page number(in my case it was sheet number) where I want the hyperlink to take me. If you want you can also use the following property : Integer.valueOf($V{REPORT_COUNT}).
Thanks everyone for the response.
For navigation within reports I have implemented using Hyperlinks and Anchors
Below is the text field with hyperlinkAnchorExpression, this will be the link.
Note the hyperlinkType="LocalAnchor"
<textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="80" y="0" width="80" height="20" forecolor="#3286C7" uuid="9a8313d2-21f3-4cd2-8e40-f9cddeb3cdaf"/>
<box topPadding="3" leftPadding="3">
<topPen lineWidth="0.2"/>
<leftPen lineWidth="0.2"/>
<bottomPen lineWidth="0.2"/>
<rightPen lineWidth="0.2"/>
</box>
<textElement>
<font isUnderline="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{cAddress}.getId()]]></textFieldExpression>
<hyperlinkAnchorExpression><![CDATA[$F{cAddress}.getId().toString()]]></hyperlinkAnchorExpression>
</textField>
Below is the anchornameexpression, this will be called when a hyperlink is clicked and values is matched with the hyperlinkAnchorExpression value anywhere in the report.
</textField>
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="80" y="0" width="80" height="20" uuid="9a8313d2-21f3-4cd2-8e40-f9cddeb3cdaf"/>
<box topPadding="3" leftPadding="3">
<topPen lineWidth="0.2"/>
<leftPen lineWidth="0.2"/>
<bottomPen lineWidth="0.2"/>
<rightPen lineWidth="0.2"/>
</box>
<textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
<anchorNameExpression><![CDATA[$F{id}.toString()]]></anchorNameExpression>
</textField>
I have implemented this to navigate across reports and subreports.
Hope this will be helpful.

Resources