Hi smile,
Use Arial font.
Please refer below sample.
Namespaces
C#
using iTextSharp.text.pdf;
using iTextSharp.text;
Code
C#
public Form1()
{
InitializeComponent();
this.BindDataGridView();
}
private void BindDataGridView()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] {
new DataColumn("Category", typeof(string)),
new DataColumn("Question",typeof(string)) });
dt.Rows.Add("تتوفر مواقف سيارات خاصة بالمنشأة","الخدمات العامة");
dt.Rows.Add("مواقف السيارات مسفلته", "الخدمات العامة");
dt.Rows.Add("يحتوي المدخل على حواجز جانبية مساندة", "مواقف السيارات");
dt.Rows.Add("يتوفر مكان مخصص للنفايات الطبية محكم الاغلاق", "حالة المنشأة");
this.dGVCup.DataSource = dt;
}
private void btnExportPdf_Click(object sender, EventArgs e)
{
//Creating iTextSharp Table from the DataTable data
PdfPTable pdfTable = new PdfPTable(dGVCup.ColumnCount);
pdfTable.DefaultCell.Padding = 2;
pdfTable.WidthPercentage = 75;
pdfTable.HorizontalAlignment = Element.ALIGN_LEFT;
pdfTable.DefaultCell.BorderWidth = 1;
//Adding Header row
foreach (DataGridViewColumn column in dGVCup.Columns)
{
PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText));
cell.BackgroundColor = new iTextSharp.text.Color(240, 240, 240);
cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL;
pdfTable.AddCell(cell);
}
//Adding DataRow
foreach (DataGridViewRow row in dGVCup.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
BaseFont bf = BaseFont.CreateFont(Environment.GetEnvironmentVariable("windir") + @"\fonts\Arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.BOLD);
PdfPCell pdfCell = new PdfPCell(new Phrase(12, cell.Value.ToString(), font));
pdfCell.RunDirection = PdfWriter.RUN_DIRECTION_RTL;
pdfTable.AddCell(pdfCell);
}
}
//Exporting to PDF
string folderPath = "C:\\PDFs\\";
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
using (FileStream stream = new FileStream(folderPath + "Arabics.pdf", FileMode.Create))
{
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
PdfWriter.GetInstance(pdfDoc, stream);
pdfDoc.Open();
pdfDoc.Add(pdfTable);
pdfDoc.Close();
stream.Close();
}
}
Screenshot