Solved

Use Regional language in pdf using itext

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 74
program arguments vs VM arguments 4 26
DTD and JAVA versions 1 28
Java List 4 33
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.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
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…

740 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