如何正确导出PDF格式时正确显示印地文? [英] How can I render hindi correctly when exporting to pdf?

查看:342
本文介绍了如何正确导出PDF格式时正确显示印地文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用i-report 5.5.0进行jasper报告。我需要将印地文文本导出为PDF格式,但是印地语部分转换为 ???????



我已经使用了字体扩展,但没有帮助:
$ b


字体名称:lohit : PDF嵌入:检查 PDF
编码
:身份-H

我也尝试了其他的印地文字体,但是到目前为止没有任何工作..

 <文本框> 
< reportElement x =111y =26width =100height =20uuid =5a471a16-de7b-4f55-9c9f-b01d37938b9f/>
< textElement>
< / textElement>
< textFieldExpression><![CDATA [$ F {DISTRICT_NAME}]]>< / textFieldExpression>
< / textField>


解决方案

正确的方法是使用



如果您喜欢尝试,请使用字体扩展名为Lohit Devanagari ,记得设置 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:

font name: "lohit Devanagari"
PDF embedded: checked
PDF encoding:Identity-H

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:

  1. Is my actual .tff supported (OpenType) and can the font actually render the character. Not all fonts render all characters in UTF-8

Once you have created correctly font extension and its not working this is probably your problem..

  1. Do I pass correct encoding to iText. In doubts (or in general) use the encoding Identity-H this is recommend for newer PDF standards and gives you the ability to mix different encoding.

Identity-H seems ok

  1. Is my font embedded so that if I share the pdf also computers not having this font can display the content.

Embed your font (otherwise if you make it work on your computer it may not work on others), note in your jrxml is isPdfEmbedded=false, remove tag and in font-extension select true or set tag to true.

Now just generate the font-extension correctly and add it to your classpath,

How to add font extensions

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:

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格式时正确显示印地文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆