Jannis Alexakis Jannis Alexakis - 5 months ago 81
Java Question

Checkbox character in iText

I am trying to insert a checkbox character into my pdf like this :

Phrase phrase = new Phrase("\u2610 somemoretext", somefont);

The "somemoretext"-portion of the String is beeing displayed correctly, the checkbox character isnĀ“t. Do i have to use something specific as a Font for this character, or what else could I be doing wrong?


You have to use a font and encoding that contains those characters. Your best bet is to use IDENTITY_H for your encoding, as this grants you access to every character within a given font:

Font font = FontFactory.getFont(f.getName(),BaseFont.IDENTITY_H);

but you still have to use the right font. This link could prove to be of help to you too


I also see different Fonts use different conversion codes/sequences:

Use a corresponding character in a different font. For instance in Wingdings.ttf you have 0x6F and 0x70