java - jaspertreport v.6.1.1: font extension not working for international language -


i'm new jasper report. i'm trying display thai characters in pdf using font extensions reason characters not displayed. i've researched on issue , followed official documentation (http://jasperreports.sourceforge.net/sample.reference/fonts/) didn't work.

i use tibco jaspersoft studio design , displayed correctly when preview design via jaspersoft studio. however, when applied generated jrxml file java code thai characters not displayed in pdf file. tried in html file , worked fine.

following official documentation generate pdf, i'm recommended export jar file containing ttf files, jasperreports_extension.properties , fonts.xml files.

please @ code snippets

fontsfamily1445966397265.xml

<?xml version="1.0" encoding="utf-8"?> <fontfamilies>   <fontfamily name="tahoma">     <normal>fonts/tahoma/tahoma.ttf</normal>     <bold>fonts/tahoma/tahomabd.ttf</bold>     <pdfencoding>identity-h</pdfencoding>     <pdfembedded>true</pdfembedded>     <exportfonts>   <export key="xhtml">tahoma</export>   <export key="html">tahoma</export> </exportfonts> 

jasperreports_extension.properties

net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.simplefontextensionsregistryfactory net.sf.jasperreports.extension.simple.font.families.ireportfamily1445966397265=fonts/fontsfamily1445966397265.xml 

java code

jaspercompilemanager.compilereporttofile(jrxml_file); string printfilename = jasperfillmanager.fillreporttofile(jasper_file, params, conn); jasperexportmanager.exportreporttopdffile(printfilename, pdf_file); 

jrxml file

<?xml version="1.0" encoding="utf-8"?> <!-- created jaspersoft studio version 6.1.1.final using jasperreports library version 6.1.1  --> <!-- 2015-10-28t01:17:50 --> <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="receipt" pagewidth="595" pageheight="842" whennodatatype="allsectionsnodetail" columnwidth="535" leftmargin="20" rightmargin="20" topmargin="20" bottommargin="20" uuid="4eedbb89-b4f6-4469-9ab6-f642a1688cf7"> <property name="template.engine" value="tabular_template"/> <style name="title" forecolor="#ffffff" fontname="tahoma" fontsize="50" isbold="false"/> <style name="subtitle" forecolor="#cccccc" fontname="tahoma" fontsize="18" isbold="false"/> <style name="column header" forecolor="#666666" fontname="tahoma" fontsize="14" isbold="false"/> <style name="detail" mode="transparent" fontname="tahoma"/> <style name="row" mode="transparent" fontname="tahoma">     <conditionalstyle>         <conditionexpression><![cdata[$v{report_count}%2 == 0]]></conditionexpression>         <style mode="opaque" backcolor="#eeeff0"/>     </conditionalstyle> </style> <style name="table">     <box>         <pen linewidth="1.0" linecolor="#000000"/>         <toppen linewidth="1.0" linecolor="#000000"/>         <leftpen linewidth="1.0" linecolor="#000000"/>         <bottompen linewidth="1.0" linecolor="#000000"/>         <rightpen linewidth="1.0" linecolor="#000000"/>     </box> </style> <style name="table_th" mode="opaque" backcolor="#ffffff">     <box>         <pen linewidth="0.5" linecolor="#000000"/>         <toppen linewidth="0.5" linecolor="#000000"/>         <leftpen linewidth="0.5" linecolor="#000000"/>         <bottompen linewidth="0.5" linecolor="#000000"/>         <rightpen linewidth="0.5" linecolor="#000000"/>     </box> </style> <style name="table_ch" mode="opaque" backcolor="#caced0">     <box>         <pen linewidth="0.5" linecolor="#000000"/>         <toppen linewidth="0.5" linecolor="#000000"/>         <leftpen linewidth="0.5" linecolor="#000000"/>         <bottompen linewidth="0.5" linecolor="#000000"/>         <rightpen linewidth="0.5" linecolor="#000000"/>     </box> </style> <style name="table_td" mode="opaque" backcolor="#ffffff">     <box>         <pen linewidth="0.5" linecolor="#000000"/>         <toppen linewidth="0.5" linecolor="#000000"/>         <leftpen linewidth="0.5" linecolor="#000000"/>         <bottompen linewidth="0.5" linecolor="#000000"/>         <rightpen linewidth="0.5" linecolor="#000000"/>     </box>     <conditionalstyle>         <conditionexpression><![cdata[$v{report_count}%2 == 0]]></conditionexpression>         <style backcolor="#d8d8d8"/>     </conditionalstyle> </style> <subdataset name="tabledataset" uuid="6590503c-ab84-4f89-80d9-38ac71dd1404">     <property name="com.jaspersoft.studio.data.defaultdataadapter" value="new data adapter "/>     <property name="com.jaspersoft.studio.data.sql.tables" value=""/>     <parameter name="customer_id" class="java.lang.long"/>     <querystring>         <![cdata[select l.name, lbd.buy_type, lbd.buy_price, (lbd.buy_price - down_payment) debt land l inner join land_buy_detail lbd on l.id = lbd.land_id  lbd.customer_id = $p{customer_id}]]>     </querystring>     <field name="name" class="java.lang.string"/>     <field name="buy_type" class="java.lang.string"/>     <field name="buy_price" class="java.lang.float"/>     <field name="debt" class="java.lang.float"/> </subdataset> <parameter name="customer_id" class="java.lang.long">     <parameterdescription><![cdata[]]></parameterdescription>     <defaultvalueexpression><![cdata[$p{customer_id}]]></defaultvalueexpression> </parameter> <querystring>     <![cdata[select firstname, lastname, address, tel customer id = $p{customer_id}]]> </querystring> <field name="firstname" class="java.lang.string"/> <field name="lastname" class="java.lang.string"/> <field name="address" class="java.lang.string"/> <field name="tel" class="java.lang.string"/> <title>     <band height="357" splittype="stretch">         <statictext>             <reportelement x="0" y="90" width="84" height="25" uuid="57aed2b1-4f4e-40a3-a6ad-54dae8dd4c5a">                 <property name="local_mesure_unitheight" value="pixel"/>                 <property name="com.jaspersoft.studio.unit.height" value="px"/>             </reportelement>             <textelement>                 <font size="16" isbold="true"/>             </textelement>             <text><![cdata[bill to:]]></text>         </statictext>         <line>             <reportelement x="0" y="80" width="556" height="1" uuid="806ce5df-1219-4876-ae0c-ca7405b1f246">                 <property name="local_mesure_unitheight" value="pixel"/>                 <property name="com.jaspersoft.studio.unit.height" value="px"/>             </reportelement>         </line>         <statictext>             <reportelement x="415" y="10" width="50" height="20" uuid="0f86baff-6386-4f3f-b3fe-2388707babe8"/>             <box rightpadding="4"/>             <textelement textalignment="right"/>             <text><![cdata[date:]]></text>         </statictext>         <textfield pattern="eeeee dd mmmmm yyyy">             <reportelement x="465" y="10" width="84" height="20" uuid="bb10dbe1-0a4f-4722-9953-c163b63cf979"/>             <textfieldexpression><![cdata[new java.util.date()]]></textfieldexpression>         </textfield>         <image halign="center">             <reportelement x="0" y="0" width="65" height="60" uuid="94883631-a913-43e2-b182-ab8d77d0181e"/>             <imageexpression><![cdata["invoice_logo.png"]]></imageexpression>         </image>         <textfield pattern="eeeee dd mmmmm yyyy">             <reportelement x="465" y="30" width="84" height="20" uuid="3836ce65-eca3-4cad-a6de-b1818def0a2b"/>             <textfieldexpression><![cdata["inv0001"]]></textfieldexpression>         </textfield>         <statictext>             <reportelement x="415" y="30" width="50" height="20" uuid="0b3f9342-da78-4cfa-9fc5-2301c4749678"/>             <box rightpadding="4"/>             <textelement textalignment="right"/>             <text><![cdata[invoice:]]></text>         </statictext>         <statictext>             <reportelement x="95" y="0" width="205" height="25" uuid="e622555d-198b-4ccd-a4a1-c59c53304058">                 <property name="local_mesure_unitheight" value="pixel"/>                 <property name="com.jaspersoft.studio.unit.height" value="px"/>             </reportelement>             <textelement>                 <font size="19" isbold="true"/>             </textelement>             <text><![cdata[bp property]]></text>         </statictext>         <statictext>             <reportelement x="95" y="55" width="205" height="15" uuid="b8cc42fd-b569-497d-834d-7e854040ad18"/>             <textelement>                 <font fontname="tahoma"/>             </textelement>             <text><![cdata[08-19595-240]]></text>         </statictext>         <statictext>             <reportelement x="95" y="25" width="205" height="15" uuid="c226e44d-3bb5-4145-b0b3-903bf1d79fde"/>             <textelement markup="none">                 <font fontname="tahoma" size="11" isbold="false"/>             </textelement>             <text><![cdata[1174 ถ. เพชรเกษม อ. หาดใหญ่]]></text>         </statictext>         <statictext>             <reportelement positiontype="fixrelativetobottom" x="95" y="40" width="205" height="15" uuid="b96f7183-44f8-43ad-ba60-43d8fbf50b6e"/>             <textelement>                 <font fontname="tahoma"/>             </textelement>             <text><![cdata[ต. หาดใหญ่ จ. สงขลา  90110]]></text>         </statictext>         <textfield>             <reportelement x="0" y="115" width="120" height="15" uuid="0e5185a4-3292-4051-927f-7e07f549bceb"/>             <textfieldexpression><![cdata[new string($f{firstname} + " " + $f{lastname})]]></textfieldexpression>         </textfield>         <textfield>             <reportelement x="0" y="130" width="120" height="15" uuid="0925d7fe-e543-4225-b44e-ff1828d6cb8a"/>             <textfieldexpression><![cdata[$f{address}]]></textfieldexpression>         </textfield>         <textfield>             <reportelement x="0" y="145" width="120" height="15" uuid="199db39e-5210-4d3a-a0c5-baf4543d9d49"/>             <textfieldexpression><![cdata[$f{tel}]]></textfieldexpression>         </textfield>         <componentelement>             <reportelement x="0" y="166" width="555" height="130" uuid="b8e9c2ed-feb3-408c-b9be-6aebbeb6af52"/>             <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemalocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">                 <datasetrun subdataset="tabledataset" uuid="6ea978fd-ffe0-40bb-84a7-f09b1f220cfa">                     <datasetparameter name="customer_id">                         <datasetparameterexpression><![cdata[$p{customer_id}]]></datasetparameterexpression>                     </datasetparameter>                     <connectionexpression><![cdata[$p{report_connection}]]></connectionexpression>                 </datasetrun>                 <jr:column width="190" uuid="06d1364f-8060-496c-ac0c-b44946e09dd0">                     <jr:columnheader style="table_ch" height="30">                         <statictext>                             <reportelement key="" style="column header" x="0" y="0" width="190" height="30" forecolor="#000000" uuid="93321529-b12d-4528-8316-4e6e94a6c476">                                 <property name="com.jaspersoft.studio.unit.x" value="pixel"/>                             </reportelement>                             <box leftpadding="2"/>                             <textelement textalignment="center" verticalalignment="middle">                                 <font fontname="tahoma" size="12" isbold="true"/>                             </textelement>                             <text><![cdata[รายการ]]></text>                         </statictext>                     </jr:columnheader>                     <jr:detailcell style="table_td" height="30">                         <textfield>                             <reportelement style="detail" x="0" y="0" width="190" height="30" uuid="4be9692f-e0bf-4a89-9f21-b579d46c9adf">                                 <property name="com.jaspersoft.studio.unit.x" value="pixel"/>                             </reportelement>                             <box leftpadding="2"/>                             <textelement textalignment="left" verticalalignment="middle">                                 <font fontname="tahoma" size="12"/>                             </textelement>                             <textfieldexpression><![cdata["   " + $f{name}]]></textfieldexpression>                         </textfield>                     </jr:detailcell>                 </jr:column>                 <jr:column width="90" uuid="25357c6d-7a1a-4bcb-ac60-8d18805b681c">                     <jr:columnheader style="table_ch" height="30">                         <statictext>                             <reportelement x="0" y="0" width="90" height="30" forecolor="#000000" uuid="c8f288aa-8d2e-48ce-8ee7-d710740d7b52"/>                             <box leftpadding="2"/>                             <textelement textalignment="center" verticalalignment="middle">                                 <font fontname="tahoma" size="12" isbold="true"/>                             </textelement>                             <text><![cdata[ประเภท]]></text>                         </statictext>                     </jr:columnheader>                     <jr:detailcell style="table_td" height="30">                         <textfield>                             <reportelement style="detail" x="0" y="0" width="90" height="30" uuid="6735552d-0796-499f-af74-e308260bc5e0"/>                             <box leftpadding="2"/>                             <textelement textalignment="left" verticalalignment="middle">                                 <font fontname="tahoma" size="12"/>                             </textelement>                             <textfieldexpression><![cdata[($f{buy_type}.equals("c")) ? "   สด" : "   ผ่อน"]]></textfieldexpression>                         </textfield>                     </jr:detailcell>                 </jr:column>                 <jr:column width="120" uuid="18cfa391-26d8-4a47-8e88-a7d1bef16d74">                     <jr:columnheader style="table_ch" height="30">                         <statictext>                             <reportelement key="" style="column header" x="0" y="0" width="120" height="30" forecolor="#000000" uuid="fc75656e-008d-47b4-ab25-2cdb62acb876"/>                             <box leftpadding="2"/>                             <textelement textalignment="center" verticalalignment="middle">                                 <font fontname="tahoma" size="12" isbold="true"/>                             </textelement>                             <text><![cdata[ราคาซื้อ]]></text>                         </statictext>                     </jr:columnheader>                     <jr:detailcell style="table_td" height="30">                         <textfield>                             <reportelement style="detail" x="0" y="0" width="120" height="30" uuid="db5ac821-df67-42ec-8f12-c3cbce27a8fd"/>                             <box leftpadding="2"/>                             <textelement textalignment="left" verticalalignment="middle">                                 <font fontname="tahoma" size="12"/>                             </textelement>                             <textfieldexpression><![cdata["   " + $f{buy_price}]]></textfieldexpression>                         </textfield>                     </jr:detailcell>                 </jr:column>                 <jr:column width="155" uuid="c192f0f1-d7f3-4362-8149-f9d592cdac30">                     <jr:columnheader style="table_ch" height="30">                         <statictext>                             <reportelement key="" style="column header" stretchtype="relativetotallestobject" x="0" y="0" width="155" height="30" forecolor="#000000" uuid="2c3771ca-3b46-4bae-837b-88fac22baff7"/>                             <box leftpadding="2"/>                             <textelement textalignment="center" verticalalignment="middle">                                 <font fontname="tahoma" size="12" isbold="false"/>                             </textelement>                             <text><![cdata[ยอดคงค้าง]]></text>                         </statictext>                     </jr:columnheader>                     <jr:detailcell style="table_td" height="30">                         <textfield pattern="#,###.##">                             <reportelement style="detail" x="10" y="0" width="145" height="30" uuid="94659f20-5913-48a2-b64c-683d0584936c"/>                             <box leftpadding="2"/>                             <textelement textalignment="left" verticalalignment="middle">                                 <font size="12"/>                             </textelement>                             <textfieldexpression><![cdata[$f{debt}]]></textfieldexpression>                         </textfield>                     </jr:detailcell>                 </jr:column>             </jr:table>         </componentelement>         <statictext>             <reportelement positiontype="float" mode="opaque" x="0" y="290" width="556" height="30" backcolor="#e6e8e9" uuid="36aa233d-4305-48e6-974a-1bbf89bb3c8f"/>             <textelement textalignment="center" verticalalignment="middle">                 <font fontname="tahoma" size="9" isitalic="true"/>             </textelement>             <text><![cdata[thankyou business]]></text>         </statictext>     </band> </title> <summary>     <band height="293" splittype="stretch">         <property name="local_mesure_unitheight" value="pixel"/>     </band> </summary> 

i'm sure jar file in maven classpath.

i'm using jaspersoft studio version 6.1.1.final using jasperreports library version 6.1.1.

i solved issue. forgot point jasper_file variable right file. solution displaying international characters worked :)


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -