3

I'm using iText 5.5.5 to generate a PDF file containing Persian and English characters, simultaneously. So, I used the following code:

document.open();

Paragraph p1 = new Paragraph();

BaseFont myFont = BaseFont.createFont("assets/fonts/droidNaskh.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font paraFont= new Font(myFont, 12);

p1.setAlignment(Paragraph.ALIGN_CENTER);
p1.setFont(paraFont);
p1.add("متن فارسی همراه با english text");

PdfPTable table = new PdfPTable(1);
PdfPCell cell = new PdfPCell(p1);
cell.setBorder(0);
cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
table.addCell(cell);

document.add(table);

However, the English part of my paragraph (i.e. "english text") is not written in the output.

1 Answers1

2

The solution is using a font with Full Language Support of Basic Latin, Persian (Farsi), Western European and Arabic. I found some fonts on OpenFontLibrary such as XB Yagut and XB Zar.