C#, visual studio 2015, desktop application, iTextSharp. I need only Bahini in SutonnyMJ font and another in Arial font. How is it possible, please provide me a link that I can understand.
This is my code:
int totalfonts = FontFactory.RegisterDirectory(Environment.CurrentDirectory);
StringBuilder sb = new StringBuilder();
PdfPTable table = new PdfPTable(12);
PdfPTable pdfTable = new PdfPTable(dataGridView1AP.ColumnCount);
iTextSharp.text.Font fontTable = FontFactory.GetFont("Arial", 9, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
iTextSharp.text.Font fontTable2 = FontFactory.GetFont("SutonnyMJ", 10, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
//Adding Header row
foreach (DataGridViewColumn column in dataGridView1AP.Columns)
{
PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText, fontTable));
pdfTable.AddCell(cell);
}
//Adding DataRow
foreach (DataGridViewRow row in dataGridView1AP.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
pdfTable.AddCell(new PdfPCell(new Phrase(cell.Value.ToString(), fontTable2)) {Border = PdfPCell.BOTTOM_BORDER, Padding = 5, MinimumHeight = 30, PaddingTop = 5 });
}
}
doc.Open();
doc.Add(new Paragraph(sb.ToString()));
doc.Add(table);
doc.Add(pdfTable);
doc.Close();
Nilesh JoshiPosted Aug 29, 2017, 4:27 PM
Here are few pointers
Is “SutonnyMJ” font installed on your system?
Were you able create instance of Font?
Try using BaseFont.CreateFont for Bahini
Try adding reference if iTextAsian.dll in your project
Here is pretty good link https://www.mikesdotnetting.com/article/81/itextsharp-working-with-fonts