Shovan Saha

Shovan Saha

  • NA
  • 321
  • 91.9k

Please check my code : font problem

Aug 26 2017 4:25 AM
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();
 
 
 
 
 
 
 
 

Answers (1)