Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
827 views
in Technique[技术] by (71.8m points)

jasper reports - How to export fonts in Gujarati-Indian Language to pdf?

I wanted to show different fonts(Gujarati-Indian Language) in Exported report of PDF from jasper report version 5.1.

What i have tried : After Running Tool open below location Step 1:

Tools -> Option -> Fonts

net.sf.jasperreports.default.font.name=Arial Unicode MS - the default     font name.
net.sf.jasperreports.default.font.size=10 - the default font size.
net.sf.jasperreports.default.pdf.font.name=Identity-H - the default PDF font.
net.sf.jasperreports.default.pdf.encoding=UTF-8 - the default PDF character encoding.
net.sf.jasperreports.default.pdf.embedded=true - by default PDF fonts are not embedded

Fonts "Arial Unicode MS" installed and its jar file also created.Jar files exits in class path of jasper report.

Link Followed :1) Fonts 2) Sample fonts

Step 2 : irfonts.xml

By default jasper report gives other fonts in this file i changed it to.

<fontFamily name="Arial Unicode MS">
<normal>net/sf/jasperreports/fonts/dejavu/ArialUnicodeMS.ttf</normal>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>

Step 3:

What result i am getting: ????? What i actually wanted: ?????

After Spending some time i came to know when you render a page in Template of Jasper report Fonts are working as per need but when you export it to pdf it changes Reason all the fonts goes through "itext pdf engine".

Now, trick is itext do not have fonts what I am currently using.

Is there any way by which I can achieve this.

Notes: It's not created using Java.I'm a Oracle Database Developer so created using tool only and printing withing tools boundaries.

Followed this blog also but it is in java so don't know where make changes. Blog of java

Sample Code:

<textField>
<reportElement x="111" y="26" width="100" height="20" uuid="5a471a16-de7b-4f55-9c9f-b01d37938b9f"/>
 <textElement>
    <font fontName="Arial Unicode MS" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{my_column_values}]]></textFieldExpression>

Some the similar questions are also in stack overflow but all of them uses java to call and print.

So, can I change itext library or any other workaround will be fine. How i created :

1) Jasper report

2) Jasper

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try JasperReports 6.2.0 or newer. It comes with PDF support for Indic scripts (achieved by transporting the AWT text layout to PDF).

The Unicode report sample (under demo/samples/unicode) from the JasperReports distribution shows texts in several Indic scripts, including Gujarati (using Google Noto fonts).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...