在jasper pdf报告中打印泰国字符的问题

时间:2015-11-10 12:46:45

标签: jasper-reports

我正面临打印jasper pdf报告的问题,其中包含泰文或中文字符。报告生成但是代替泰国字符显示????符号。

3 个答案:

答案 0 :(得分:1)

您需要将泰语/中文字符的ttf字体添加为扩展名。

最简单的方法是通过ireport-designer

  1. 下载(或在您的电脑上使用一个)您想要的ttf字体(针对特定语言)。
  2. 在ireport中安装字体
  3. 导出字体扩展名(这会创建.jar)
  4. 将jar添加到类路径中。
  5. 这是iReport

    中这些步骤Jasper soft studio的链接

    我会尝试PDF编码: Idenity-H (带水平书写的unicode)

答案 1 :(得分:0)

首先,您需要遵循本指南。 https://community.jaspersoft.com/wiki/displaying-east-asian-characters-report-pdf-output

如果您使用过maven,则需要向pom.xml文件中添加以下依赖项

        <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>

注意:您需要将Arial Unicode库安装到本地Maven存储库。请使用以下命令

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

现在您需要构建您的项目,应该没问题。

答案 2 :(得分:-1)

http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"命名=&#34; jasper_report_template&#34;页宽=&#34; 595&#34; pageHeight =&#34; 842&#34; whenNoDataType =&#34; NoPages&#34; columnWidth时=&#34; 515&#34; LEFTMARGIN =&#34; 40&#34; rightMargin =&#34; 40&#34; TOPMARGIN =&#34; 50&#34; bottomMargin =&#34; 50&#34; UUID =#&34; e35f5797-7de3-4d8d-ba9e-5320acff8a13&#34;&GT;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

        ]]></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>