【问题标题】:Bangla font in pdf not show correctly in iReportpdf 中的 Bangla 字体在 iReport 中无法正确显示
【发布时间】:2017-12-04 10:48:57
【问题描述】:

我使用 iReport 5.6.0 来构建报告。我在静态字段中使用了 SolaimanLipi 字体。 iReport 内部视图没问题,但保存为 pdf 后(在 pdf 阅读器或任何浏览器中打开)bangla 字体无法正确显示。
jrxml代码:

 <?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="challanReport" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="770" leftMargin="54" rightMargin="18" topMargin="20" bottomMargin="20" uuid="9126e000-dc70-4a76-9013-4a4fa290f0df">
<pageHeader>
    <band height="273" splitType="Stretch">
        <staticText>
            <reportElement x="13" y="10" width="403" height="20" uuid="1d2c7070-63f4-4a43-b3a2-63dc4c27c6f2"/>
            <textElement>
                <font fontName="SolaimanLipi" pdfEncoding="Identity-H"/>
            </textElement>
            <text><![CDATA[বাংলাদেশ ব্যাংক/সোনালী ব্যাংকের ....ঢাকা....জেলার....মহাখালী....শাখায় টাকা জমা দেওয়ার চালান ।]]></text>
        </staticText>
        <staticText>
            <reportElement x="429" y="10" width="69" height="20" uuid="21401d70-386e-4f01-bf34-586d58991b62"/>
            <box>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center">
                <font fontName="SolaimanLipi" pdfFontName="Helvetica" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
            </textElement>
            <text><![CDATA[১ম(মূল)কপি]]></text>
        </staticText>
        <staticText>
            <reportElement x="13" y="50" width="512" height="60" uuid="ee6769a0-b25e-4f60-b783-58b535f955d7"/>
            <box leftPadding="4">
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement>
                <font fontName="SolaimanLipi" pdfEncoding="Identity-H"/>
            </textElement>
            <text><![CDATA[বিভাগের নাম এবং চালানের পৃষ্ঠাংকনকারী  কর্মকর্তার নাম, পদবী ও দপ্তর l *]]></text>
        </staticText>
        <staticText>
            <reportElement x="13" y="30" width="512" height="20" uuid="1e86fa4b-88a3-4e05-b37a-3a4dbd0b2963"/>
            <box>
                <topPen lineWidth="0.25"/>
                <leftPen lineWidth="0.25"/>
                <bottomPen lineWidth="0.25"/>
                <rightPen lineWidth="0.25"/>
            </box>
            <textElement textAlignment="Center">
                <font fontName="SolaimanLipi" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
            </textElement>
            <text><![CDATA[জমা প্রদানকারী কর্তৃক পূরণ করিতে হইবে |]]></text>
        </staticText>
    </band>
</pageHeader>

iReport 内部视图:

iReport 外部视图:
如何解决这个问题?

【问题讨论】:

  • 你在使用字体扩展吗?
  • @AlexK 没有。我使用了 Identity-H(横向书写的 Unicode)和 pdf 嵌入 true
  • @Rafiq,你找到解决方案了吗?我面临同样的问题..

标签: jasper-reports export-to-pdf


【解决方案1】:

使用 jasper 报告在 pdf 中正确显示任何类型的 Unicode 字体

第一步

  • 下载您想要的 Unicode 字体 xxx.ttf 扩展名
  • 在jasper studio中安装此字体font Installation instruction

  • 现在在您的报告中使用此自定义字体

第二步

  • 从 Jaspersoft-studio 导出您的自定义字体 jar
  • 在 java 构建路径中添加此字体 jar 或在 maven 存储库中安装此字体

如果您在项目构建路径中手动添加字体,则忽略字体安装过程。

字体安装命令

mvn install:install-file -Dfile=/your-jar-file-directory/fontName.jar -DgroupId=bangla -DartifactId=bangla -Dversion=1.0 -Dpackaging=jar

安装字体jar后,你需要在你的pom文件中添加依赖

示例依赖示例

       <dependency>
            <groupId>bangla</groupId>
            <artifactId>bangla</artifactId>
            <version>1.0</version>
        </dependency>

【讨论】:

    猜你喜欢
    • 2023-01-28
    • 1970-01-01
    • 1970-01-01
    • 2020-12-05
    • 1970-01-01
    • 2014-10-11
    • 1970-01-01
    • 2015-12-30
    • 1970-01-01
    相关资源
    最近更新 更多