How to add the symbol ₺ (Turkish Lira) in iReport
$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 is how to add $P{DETAILPARAM} to the parameter. And export the PDF, but don’t show “₺” this character.
What should I do?
Turkish Lira has unicode U+20BA , and since it is fairly new (2012), you must be sure that this Unicode is supported by the font of your choice.
I tried with the font dejavu-serif to understand how to download and install correctly: 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, it is better to use
pattern, as this will support the correct class if exported, for example, to excel.I couldn’t reach the template
"\u20BA #,##0.00", even if it works directly in java, I need to continue investigating this, it seems that the jasper report does the replacement "\" should have placed the char directly in the template (even if this is not recommended).
