$P{DETAILPARAM} = " Tarihinden bu güne kadar <style isBold='true' pdfFontName='DejaVu Sans'>"+new java.text.DecimalFormat("#,##0.00").format($F{TOTAL_DEBT})+" ₺ </style> Borcunuz vardır."
Font = DejaVu Sans
This like add $P{DETAILPARAM}
in parameter. And export PDF, but do not show "₺" this symbol.
What must I do?
The Turkish Lira has unicode U+20BA
and since it fairly new (2012) you need to be sure that this unicode is supported by your selected font .
I tried with the font dejavu-serif, to understand how to download and install correctly see: How can I display "$£Ω€απ⅔" in Jasperserver PDF using iReport?
Result
This was my jrxml code:
<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="FontTest" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="2347c131-1884-430a-b77f-59f08f896c8a">
<parameter name="number" class="java.lang.Double" isForPrompting="false">
<defaultValueExpression><![CDATA[new Double(1000.23)]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<title>
<band height="25">
<textField>
<reportElement x="0" y="0" width="100" height="25" uuid="bc2ae040-f9af-4732-82fe-8fe8b71696bd"/>
<textElement>
<font fontName="DejaVu Serif" size="14"/>
</textElement>
<textFieldExpression><![CDATA["\u20BA"]]></textFieldExpression>
</textField>
<textField pattern="₺ #,##0.00">
<reportElement x="100" y="0" width="200" height="25" uuid="ee49d149-394b-4ac6-a0a2-6d207b0c8d89"/>
<textElement>
<font fontName="DejaVu Serif" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$P{number}]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
Some design notes:
When formatting numbers it is better to apply pattern
, since this will keep correct class if exported to for example excel.
I could not achieve the pattern "\u20BA #,##0.00"
even if this works directly in java, I need to further investigate this, seems like jasper report is doing a replacement of the "\" had to put the char directly in pattern (even if this is not recommend).