Search code examples
javaswingspecial-charactersitext

Unicode characters in iText PDF


I need help with iText I look at some Google result and some here but don't find anything that work for me. I need to use polish character in my pdf but i got nothing for no. Here is a code that I think is important if need something else write in comment:

private static Font bigFont = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD);

another

Paragraph par = new Paragraph(Łabadzak, bigFont);

Can any1 tell me what to do to make that Ł visible in pdf and other polish character

UPDATE I fund this but dunno how to use it for my project Polish character in itext PDF


Solution

  • You need a unicode font. Here is an example:

    BaseFont bf = BaseFont.createFont("arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    
    Paragraph p = new Paragraph("Şinasi ıssız ile ağaç", new Font(bf, 22));
    
    document.add(p);
    

    http://abdullahakay.blogspot.com/2011/11/java-itext-unicode.html

    EDIT:

    Here, the font file name arialuni.tff is a static resource directly under /src/main/resources/ and can be any Unicode Font File of your choice. Here's a list of free Unicode Font Files available online.