Issues with printing thai characters in jasper pdf

2019-03-01 21:59发布

问题:

I am facing issues with printing jasper pdf report which contains thai or chinese characters.Report is getting generated but in place of thai character it displays ???? symbols.

回答1:

You need to add the ttf font for the thai/chinese char as extension.

The easiest way to do this is through ireport-designer

  1. Download (or use one on your pc) your desired ttf font (for the specific language).
  2. Install the font in ireport
  3. Export the font extension (this creates a .jar)
  4. Add the jar to your classpath.

This is a link for these step iReport and this in Jasper soft studio

I would try PDF-Encoding: Idenity-H (unicode with horizontal writing)



回答2:

http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="jasper_report_template" pageWidth="595" pageHeight="842" whenNoDataType="NoPages" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50" uuid="e35f5797-7de3-4d8d-ba9e-5320acff8a13">

        ]]></text>
        </staticText>
        <staticText>
            <reportElement x="414" y="3" width="121" height="15" uuid="f3706214-547a-4999-ace7-23d042c980bc"/>
            <textElement textAlignment="Center" verticalAlignment="Middle">
                <font pdfEncoding="Identity-H"/>
            </textElement>
            <text><![CDATA[北京]]></text>
        </staticText>
        <staticText>
            <reportElement x="0" y="3" width="136" height="15" uuid="42357a36-3ef3-4ae7-a4c6-0bbd6c8d501a"/>
            <textElement textAlignment="Center" verticalAlignment="Middle">
                <font isBold="true"/>
            </textElement>
            <text><![CDATA[Name]]></text>
        </staticText>
    </band>
</columnHeader>
<detail>
    <band height="16" splitType="Stretch">
        <staticText>
            <reportElement mode="Opaque" x="0" y="0" width="535" height="14" backcolor="#E5ECF9" uuid="5beb0b02-caaf-4d55-8d42-f6c52e238c58"/>
            <box>
                <bottomPen lineWidth="0.25" lineColor="#CCCCCC"/>
            </box>
            <text><![CDATA[

        ]]></text>
        </staticText>
        <textField>
            <reportElement x="414" y="0" width="121" height="15" uuid="e85c199d-04cc-4a05-b0ac-6817898320e5"/>
            <textElement textAlignment="Center" verticalAlignment="Middle">
                <font size="9"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{country}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="0" y="0" width="136" height="15" uuid="339296ec-b8ba-49e7-bccc-b89c77eb3300"/>
            <textElement textAlignment="Center" verticalAlignment="Middle"/>
            <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
        </textField>
    </band>
</detail>