I'm creating a jasper report template from a page where I can upload some files as attachment. The requirement is to generate a report from the page and add a URL for the file into the generated report. If the user clicks the URL he can download the file.
When we upload a file to our system we generate a unique filename for the uploaded file.
Example: If the uploaded file was "Jaspersoft-Studio-User-Guide.pdf" the file will have a new name: "03ff52a3-c165-4f71-9d27-eedac395a41b"
I need a hyperlink which works similar to the browser file download so by accessing the file with URL: "www.test.com/03ff52a3-c165-4f71-9d27-eedac395a41b" The downloaded file name will be "Jaspersoft-Studio-User-Guide.pdf" instead of "03ff52a3-c165-4f71-9d27-eedac395a41b"
Is this possible?
I tried to use:
<textField isStretchWithOverflow="true" isBlankWhenNull="true" hyperlinkType="RemotePage" hyperlinkTarget="Blank">
<reportElement x="0" y="0" width="345" height="20" isRemoveLineWhenBlank="true" forecolor="#5A82C3" uuid="c2621a64-81fe-4847-9f25-48292d0beb46"/>
<textElement verticalAlignment="Middle" markup="html">
<font fontName="GT-Pressura"/>
</textElement>
<textFieldExpression><![CDATA[$F{filename} +"<style size='4'>" +$F{url}+ "</style>"]]></textFieldExpression>
<anchorNameExpression><![CDATA[$F{filename}]]></anchorNameExpression>
<hyperlinkReferenceExpression><![CDATA[$F{url}]]></hyperlinkReferenceExpression>
<hyperlinkTooltipExpression><![CDATA[$F{filename}]]></hyperlinkTooltipExpression>
</textField>
and with html as it is used in the browser:
<textField>
<reportElement x="290" y="90" width="254" height="20" uuid="5124e8e6-831b-49f8-9f4a-b920f6fb2277"/>
<textElement markup="html"/>
<textFieldExpression><![CDATA["<a href='localhost:8080/bb7162d3-83e5-4b7a-b65b-eaa5930924d1' download='Jaspersoft-Studio-User-Guide.pdf'> Jaspersoft-Studio-User-Guide.pdf </a>"]]></textFieldExpression>
</textField>
I expect from the link to works as a browser link so the name should be whatever I specify in the download
field.
Is this possible to achieve with hyperlink or with text field with markup="html"
or I have to create a filter which changes the downloaded file name?