Arabic Characters
Submitted by Anonymous Newbie on Mon, 03/21/2011 - 11:49
Hello,
I'm able to display English characters but I'm not able to display Arabic characters.
Can u please help me on this?
BaseFont bf_helv = BaseFont.createFont(BaseFont.HELVETICA, "Cp1256", false);
PdfContentByte cb = writer.getDirectContent();
cb.beginText();
cb.setFontAndSize(bf_helv, 12);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, text + " Center", 250, y_line1, 0);
cb.endText();
- Login to post comments
Content © 2010 1T3XT BVBA

Use the correct font and writing direction
Submitted by Bruno Lowagie on Mon, 03/21/2011 - 12:01.There are two major issues at play in your snippet:
BaseFont.Identity_H. If you use Cp1256, you tell iText to use a simple font, and you'll only be able to use 256 glyphs. For languages such as Arabic, you should use a composite font (and Unicode). Read section 11.2 to find out the difference.PdfContentByte.showTextAligned(). You need to useColumnTextif you want to add the text at an absolute position, and you need to set the run direction with thesetRunDirection()method. This is explained in section 11.3.4 entitled "Writing text from right to left".