问题描述
我将 i-report 5.5.0 用于 jasper 报告.我需要将印地语文本导出为 PDF 格式,但印地语部分正在转换为 ???????
.
我已经使用过字体扩展,但没有帮助:
字体名称:lohit Devanagari"
PDF 嵌入:选中
PDF编码:Identity-H
我也尝试过其他印地语字体,但到目前为止没有任何效果..
<reportElement x="111" y="26" width="100" height="20" uuid="5a471a16-de7b-4f55-9c9f-b01d37938b9f"/><font fontName="Lohit Devanagari" pdfEncoding="Identity-H" isPdfEmbedded="false"/></textElement><textFieldExpression><![CDATA[$F{DISTRICT_NAME}]]></textFieldExpression></textField>
正确的做法是使用
它正在渲染字体,但结果可能有Ligaturizer问题,有关如何解决这些问题,请参见例如为什么使用 Arial Unicode MS 无法正确呈现古吉拉特语-印度文本?
如果您想尝试这是我使用的字体扩展 Lohit Devanagari 的字体扩展 jar,记得设置fontName="Lohit Devanagari"
I am using i-report 5.5.0 for jasper reports. I need to export Hindi text into PDF format, but Hindi part is getting converted to ???????
.
I have already used font extension but it didn't helped:
I have also tried other Hindi fonts but nothing worked so far..
<textField>
<reportElement x="111" y="26" width="100" height="20" uuid="5a471a16-de7b-4f55-9c9f-b01d37938b9f"/>
<textElement>
<font fontName="Lohit Devanagari" pdfEncoding="Identity-H" isPdfEmbedded="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{DISTRICT_NAME}]]></textFieldExpression>
</textField>
The correct way to go is using font-extensions. pdfEncoding="Identity-H"
is deprecated.
First clear this checklist to render font in pdf:
- Is my actual
.tff
supported (OpenType) and can the font actually render the character. Not all fonts renderall characters inUTF-8
- Do I pass correct encoding to iText. In doubts (or in general) usethe encoding Identity-H this is recommend for newer PDF standardsand gives you the ability to mix different encoding.
- Is my font embedded so that if I share the pdf also computers nothaving this font can display the content.
Now just generate the font-extension correctly and add it to your classpath
,
EDIT: After user passed font
The font Krutidev_011.TTF
is not a valid ttf font it maybe because unfortunately the standard according to Apple and the standard according to Microsoft diverged (my guess your font is an apple ttf not an open type ttf).
Caused by: net.sf.jasperreports.engine.JRRuntimeException: java.awt.FontFormatException: java.nio.BufferUnderflowException
at net.sf.jasperreports.engine.fonts.SimpleFontFace.setTtf(SimpleFontFace.java:178)
I tried to download a valid ttf font Lohit Devanagari from the web and add it as font extension, fontName="Lohit Devanagari"
this is my result:
It is rendering the fonts but the result may have Ligaturizer problem, for how to solve these see for example Why is the Gujarati-Indian text not rendered correctly using Arial Unicode MS?
If you like to try this is the font-extension I used font extension jar for Lohit Devanagari, remember to set fontName="Lohit Devanagari"
这篇关于导出为 pdf 时如何正确渲染印地语?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!