Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Use Regional language in pdf using itext

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

860 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