I am generating a report from Unity3d with iTextSharp,
Problem is showing arabic characters. There is one XML file from where I am parsing some arabic text, and when I put it in PDF, it shows well. But when I put normal string in MonoDevelop, and try to show it in PDF, it shows some weird characters.
Here is my code:
Document doc = new Document(iTextSharp.text.PageSize.A4, 10, 10, 20, 20);
PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream("TestPDF.pdf", FileMode.Create));
doc.Open();
string fontPath = Application.dataPath + "\\Fonts\\Arial.ttf";
// string fontPath = Application.dataPath + "\\Fonts\\arabtype.ttf";
BaseFont basefont = BaseFont.CreateFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
string tt = GameObject.Find("TextPlay").GetComponent<TextMesh>().text; //parsed text
iTextSharp.text.Font normalFont = new iTextSharp.text.Font(basefont, 35, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
PdfPTable tableUnit = new PdfPTable(2);
tableUnit.DefaultCell.NoWrap = false;
tableUnit.RunDirection = PdfWriter.RUN_DIRECTION_RTL;
tableUnit.DefaultCell.Border = Rectangle.NO_BORDER;
tableUnit.SpacingBefore = 30f;
tableUnit.KeepTogether = true;
PdfPCell questionOneCell = new PdfPCell(new Phrase("نتائجك", normalFont));
questionOneCell.NoWrap = false;
questionOneCell.BorderWidth = 0;
questionOneCell.BackgroundColor = nColor;
questionOneCell.HorizontalAlignment = Element.ALIGN_CENTER;
questionOneCell.VerticalAlignment = Element.ALIGN_CENTER;
tableUnit.AddCell(questionOneCell);
doc.Add(tableUnit);
doc.Close();
I did try several fonts, but nothing changes.