I am trying to print Arabic text in cell inside table (in pdf) using Itext with the following code
Font f = FontFactory.getFont("C:\\Windows\\Fonts\\arabtype.ttf");
t.addCell(new Cell(new Phrase(name,f)));
Where name is an Arabic text
But it print “????” instead of the Arabic text
The default encoding for
FontFactory.getFont()(and just about everywhere else in iText) is stored in (search search) A PUBLIC STRING! That makes life easy… FontFactoryImp.defaultEncoding. This is initialized toBaseFont.WINANSI(code page (cp) 1252 if I recall correctly).I recommend setting it to
BaseFont.IDENTITY_H:The only downside to using “Identity H” is that this forces fonts using it to be embedded subsets. If you want to not embed a font, you may not use “Identity H”.