I am trying to customize list symbol with check mark. but its not working. Workaround i did with Image. Please see below sample code.
.setListSymbol("\u2022") - its working fine .setListSymbol("\u2714") or .setListSymbol("\u2713") not working
Custom list symbol is just like any other text. You have to specify the right font in order to get it work. By default iText works with Helvetica font, one of the Standard Fonts. Helvetica contains U+2022
, but does not contain U+2714
and U+2713
.
You can specify the font for the list which would contain the necessary glyph and this font will be used in the list symbol. An example of a font containing the glyphs you mention is Arial Unicode
.
List list = new List().
setFont(PdfFontFactory.createFont("C:/Windows/Fonts/arialuni.ttf", PdfEncodings.IDENTITY_H)).
setListSymbol("\u2713");
Will create a list with the list symbol you want.
If you don't want to change the font of the whole list, but only change the list symbol font, you can do it the following way:
PdfFont unicodeFont = PdfFontFactory.createFont("C:/Windows/Fonts/arialuni.ttf", PdfEncodings.IDENTITY_H);
List list = new List().
setListSymbol(new Text("\u2713").setFont(unicodeFont));