Data table to PDF with Dubai (Arabic) font using iTextSharp not working in Console Application

Last Reply 5 months ago By dharmendr

Posted 5 months ago

Dear,

I am facing one issue with ITextSharp Dubai font, I tried with the sample code its working fine but the individual character is not showing in the pdf file

eg: the sentence الخطة التشغيلية لمبادرة دراية لعام 2020 م ignore the character "م" or any another single character. Kindly guide me how to resolve this issue.

Can you please create a console application using Dubai font.

Font download link : https://dubaifont.com/download

PdfPTable hedertable = new PdfPTable(new float[] { 20, 60, 20 });
BaseFont bf1 = BaseFont.CreateFont(Server.MapPath("/fonts/") + "Dubai-Regular.ttf",BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
string cellTextm = "الخطة التشغيلية لمبادرة دراية لعام" + thisDay + "م";
iTextSharp.text.Font fontheader = new iTextSharp.text.Font(bf1, 20, iTextSharp.text.Font.NORMAL);
iTextSharp.text.pdf.PdfPCell mcell = new iTextSharp.text.pdf.PdfPCell(new Phrase(16, cellTextm, fontheader))
{ HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER };
mcell.VerticalAlignment = Element.ALIGN_MIDDLE;
mcell.RunDirection = PdfWriter.RUN_DIRECTION_RTL;
hedertable.AddCell(mcell);
//Create PDF
Document pdfDoc = new Document(PageSize.A4.Rotate(), 10f, 10f, 10f, 10f);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
pdfDoc.Add(hedertable);
pdfDoc.Add(table);
pdfDoc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();

 

This question does not have replies marked as Answer.