Issues with printing thai characters in jasper pdf report

前端 未结 3 746
离开以前
离开以前 2021-01-24 20:00

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.

相关标签:
3条回答
  • 2021-01-24 20:38

    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)

    0 讨论(0)
  • 2021-01-24 20:45

    First of all, you need to follow this guide. https://community.jaspersoft.com/wiki/displaying-east-asian-characters-report-pdf-output

    if you used maven, You need to add following dependencies to your pom.xml file

            <dependency>
                <groupId>com.test</groupId>
                <artifactId>arialunicode</artifactId>
                <version>1.0.0</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>3.2.2.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
                <version>3.2.2.RELEASE</version>
            </dependency>
    

    Note: Arial Unicode library you need to install yours to your local maven repository.Please usee below command

    mvn install:install-file -DgroupId=com.test -DartifactId=arialunicode -Dpackaging=jar -Dversion=1.0.0 -Dfile=arialunicode-1.0.0.jar -DgeneratePom=true
    

    Now you need to build your project and It should be ok.

    0 讨论(0)
  • 2021-01-24 20:47

    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>
    

    0 讨论(0)
提交回复
热议问题