Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Use Regional language in pdf using itext

Posted on 2011-02-10
5
Medium Priority
?
1,018 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
[X]
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
  • 3
  • 2
5 Comments
 

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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

721 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