Solved

Use Regional language in pdf using itext

Posted on 2011-02-10
5
929 Views
Last Modified: 2012-05-11
I am using itext in my java application. I want to use Marathi font (Marathi is a Indian Language) in my pdf. I add Marathi font in C:\Windows\font. Now How to use it in pdf Please help.
0
Comment
Question by:Aurii
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:Dejan Pažin
ID: 34868712
0
 

Author Comment

by:Aurii
ID: 34868741
But how should I import font from C:\Windows\Font\
0
 
LVL 17

Expert Comment

by:Dejan Pažin
ID: 34868794

Using FontFactory.register() method. Like this:

FontFactory.register("C:\\Windows\\Font\\yourfont", "YourFontName");
FontFactory.getFont("YourFontName", BaseFont.CP1252, BaseFont.EMBEDDED);
0
 

Author Comment

by:Aurii
ID: 34925031
I used your code as,

FontFactory.register("C:\\WINDOWS\\Fonts\\K021", "K021");
cell = new PdfPCell(new Phrase(" M/S. Askaran Vijay Foods", FontFactory.getFont("K021", BaseFont.CP1252, BaseFont.EMBEDDED)));

But its not working. Its showing some different English font but 'K021' is a Marathi font


0
 
LVL 17

Accepted Solution

by:
Dejan Pažin earned 500 total points
ID: 34925249

I downloaded k021 font from here: http://www.eshabdakosh.com/download-font.html

I extracted the file to C:\WINDOWS\Fonts\

And this is the code that I tested and shows the fonts:

FontFactory.register("C:\\Windows\\Fonts\\k021.ttf", "k021");
Font tempFont = FontFactory.getFont("k021", BaseFont.CP1252, BaseFont.EMBEDDED);
// Lets see if the font is found:
System.out.println("tempFont = " + tempFont.getFamilyname());
// Now use it:
preface.add(new Paragraph("Title of the document XX", tempFont));
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now