Solved

Use Regional language in pdf using itext

Posted on 2011-02-10
5
942 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java - Why doesn't this JFrame work 3 45
stackato and cloud 4 74
windows explorer path to command prompt 5 33
Oracle SQL syntax check  without executing 6 38
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

862 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

23 Experts available now in Live!

Get 1:1 Help Now