zoukankan      html  css  js  c++  java
  • JasperReport

    Summary

    • 导出的 pdf 文件中,中文部分不显示

    方法1:使用“华文宋体”

    • 将STSONG.TTF直接引入到我们的项目中,或者安装到我们的服务器上。
    • 修改文本域中的字体为“华文宋体(STsong)”
    • 问题是:虽然该字体使用广泛,但是涉及版权问题。

    方法2:开源字体“NotoSerifCJKsc-Regular.otf”

    • 将该字体上传到运行环境的 /opt/jdk1.8.0_241/jre/lib/fonts 目录中。
    • 在jrxml中修改对应文件字体路径
    <textField>
        <reportElement x="347" y="84" width="100" height="30" uuid="3f9d084d-3581-43a3-b638-f62834410bcf"/>
        <textElement>
            <font fontName="Noto Serif CJK SC" pdfFontName="/opt/jdk1.8.0_241/jre/lib/fonts/NotoSerifCJKsc-Regular.otf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
        </textElement>
        <textFieldExpression><![CDATA["中文w测试"]]></textFieldExpression>
    </textField>
    • 留意 pdfEncoding 和 isPdfEmbedded 参数必须设置。
    • 最后重启项目即可。
  • 相关阅读:
    POJ 2723 Get Luffy Out(2-SAT)
    ZOJ 3613 Wormhole Transport
    HDU 4085 Peach Blossom Spring
    NBUT 1221 Intermediary
    NBUT 1223 Friends number
    NBUT 1220 SPY
    NBUT 1218 You are my brother
    PAT 1131. Subway Map (30)
    ZSTU OJ 4273 玩具
    ZSTU OJ 4272 最佳淘汰算法
  • 原文地址:https://www.cnblogs.com/duchaoqun/p/12692137.html
Copyright © 2011-2022 走看看