Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Itext Arabic Font coming as question marks.

vishnu.vyasanMay 16 2011 — edited Jun 22 2011
Hello Guys,

I have a requirement where i need to provide the output[containing Arabic] as PDF. I am using Itext library for this purpose.
I created a test servlet as given below.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

response.setContentType ("application/pdf;charset=UTF-8");
Document document = new Document();
    try{
        PdfWriter.getInstance(document, 
            response.getOutputStream()); // Code 2
        document.open();

        Font f1;
  BaseFont bf  = BaseFont.createFont("C:\\WINDOWS\\Fonts\\ARIALUNI.ttf", BaseFont.CP1252, true);
  f1 = new Font(bf, 10);

        PdfPTable table = new PdfPTable(2);
        table.addCell("hellooooo1");
        table.addCell("world2");
        table.addCell("1113");
        table.addCell("422");

 // String a = "يبسبيبيبيسسسيبيببيسبيسيببي";
  String a = "سش";
  PdfPCell cell = new PdfPCell (new Paragraph (a,f1));
  table.addCell (cell);
  cell = new PdfPCell (new Paragraph ("Road",f1));
  table.addCell (cell);

        document.add(table);        
        document.close(); 
    }catch(DocumentException e){
        e.printStackTrace();
    }
}
In the output i am getting , Arabic is coming as question marks. Please tell me where i am making the mistake?

Why such an issue is coming?
Regards
Vishnu

Edited by: vishnu.vyasan on May 16, 2011 12:49 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 20 2011
Added on May 16 2011
5 comments
1,556 views