2

We are using Jasper report 4.x. It working fine with Unicode char set like arabic, Bangla with SolaimanLipi in Jasper Viewer after embedding font on jasperreports-fonts-4.5.0 . But When I trying for pdf report. Arabic & English font are rendered well, But Bangla font are not rendered hope fully.

<?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="BANGLA" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="2f940500-af46-4cbf-97d6-710e159ff606">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <queryString>
        <![CDATA[SELECT
     t01i001.`F_ID` AS ID,
     t01i001.`F_REVISION` AS REVISION,
     t01i001.`F_REGISTER_DATE` AS REGISTER_DATE,
     t01i001.`F_REGISTER_USER` AS REGISTER_USER,
     t01i001.`F_REVISION_DATE` AS REVISION_DATE,
     t01i001.`F_REVISION_USER` AS REVISION_USER,
     t01i001.`F_NAME_BN` AS NAME_BN,
     t01i001.`F_NAME_EN` AS NAME_EN
FROM
     `t01i001` t01i001]]>
    </queryString>
    <field name="ID" class="java.lang.Long"/>
    <field name="REVISION" class="java.lang.Long"/>
    <field name="REGISTER_DATE" class="java.sql.Timestamp"/>
    <field name="REGISTER_USER" class="java.lang.Integer"/>
    <field name="REVISION_DATE" class="java.sql.Timestamp"/>
    <field name="REVISION_USER" class="java.lang.Integer"/>
    <field name="NAME_BN" class="java.lang.String"/>
    <field name="NAME_EN" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="20" splitType="Stretch">
            <staticText>
                <reportElement uuid="9e2ca429-638e-4bf0-a2f9-a40c5edbecf7" x="0" y="0" width="100" height="20"/>
                <textElement/>
                <text><![CDATA[ID]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="e502c14f-a347-4fe5-bd15-fbf85d7ebeee" x="100" y="0" width="214" height="20"/>
                <textElement/>
                <text><![CDATA[NAME_EN]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="156fd960-8182-437f-8a9b-90a89467b1bc" x="314" y="0" width="241" height="20"/>
                <textElement/>
                <text><![CDATA[NAME_BN]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="20" splitType="Stretch">
            <textField>
                <reportElement uuid="1f6fc0f9-33da-4c1c-b97f-4d9e1c975958" x="0" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement uuid="1986cb1d-ca64-4edc-b74b-c6a49f2549cc" x="100" y="0" width="214" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{NAME_EN}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement uuid="4d439fed-f786-44cb-bf31-128a9e8ee3a2" x="314" y="0" width="241" height="20"/>
                <textElement>
                    <font fontName="SolaimanLipi" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{NAME_BN}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

Here i used 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.dejavu=net/sf/jasperreports/fonts/fonts.xml

In fonts.xml made following entries

<fontFamily name="SolaimanLipi">
       <normal>net/sf/jasperreports/fonts/rdp/SOLAIMANLIPI.ttf</normal>
       <bold>net/sf/jasperreports/fonts/rdp/SOLAIMANLIPI.ttf</bold>
       <italic>net/sf/jasperreports/fonts/rdp/SOLAIMANLIPI.ttf</italic>
       <boldItalic>net/sf/jasperreports/fonts/rdp/SOLAIMANLIPI.ttf</boldItalic>
       <pdfEncoding>Identity-H</pdfEncoding>
       <pdfEmbedded>true</pdfEmbedded>
</fontFamily>

Then I rebuild the jar file with own font set

For example where it rendered as below:

  1. গ োপালগঞ্ জ instead of গোপালগঞ্জ
  2. মুন্ সীগঞ্ জ instead of মুন্সীগঞ্জ
  3. ময়মনস িংহ instead of ময়মনসিংহ

I just made a virtual realization as above. Any solution?

Śhāhēēd
  • 1,812
  • 6
  • 23
  • 44
  • did you create a font extension with the Bangla font? – MrsTang Jan 07 '13 at 11:40
  • For your realization this question edited, where you will find the extension & fonts.xml. So if you have any doubt just inform me. Thanks – Śhāhēēd Jan 08 '13 at 05:11
  • @ShahedHossain: did you find any solution? I am in the same problem. – sarwar026 May 30 '17 at 07:30
  • Mr. [sarwar026](https://stackoverflow.com/users/1271985) not yet! Possible causes the [iText](https://mvnrepository.com/artifact/com.lowagie/itext) version that not supported. You can render pdf with latest version of [iText](https://mvnrepository.com/artifact/com.lowagie/itext). Where jasper using very old version of [iText](https://mvnrepository.com/artifact/com.lowagie/itext) – Śhāhēēd May 31 '17 at 08:01
  • Expected to be work with `net.sf.jasperreports:jasperreports:jar` for version [6.0.0](https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports/6.0.0), [6.0.2](https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports/6.0.2) or [6.0.3](https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports/6.0.3). – Śhāhēēd Jun 20 '18 at 09:40

1 Answers1

2

I have way-around for this problem, first need to use Bijoy encoding then use any Bijoy unicode font (DestinyMJ).

গোপালগঞ্জ bijoy encoding - > †MvcvjMÄ

{NAME_BN} = '†MvcvjMÄ';

it will print গোপালগঞ্জ correctly.

  • Good catch! You are right! For this purpose you have to develop encoder/decoder/converter. Like [`chorke-core-unijoy`](http://mvn.chorke.org/m2/releases/org/chorke/core/chorke-core-unijoy/1.0.00.GA/) developed by **Chorke, Inc**. might be helpful. Where there were some issues for English-Bengali mixing characters! – Śhāhēēd Jun 25 '18 at 12:59
  • 1
    http://mvn.chorke.org/m2/releases/org/chorke/core/chorke-core-unijoy/1.0.00.GA/ needs username and password. – Mufachir Hossain Jul 23 '20 at 08:09