Rahul Vcs
Rahul Vcs

Reputation: 43

Change Text style in itextsharp

I want to make the font bold using itextsharp. below is my code

foreach (DataGridViewColumn column in dataGridView1.Columns)
{
      iTextSharp.text.pdf.BaseFont bf = iTextSharp.text.pdf.BaseFont.CreateFont(iTextSharp.text.pdf.BaseFont.TIMES_ROMAN, iTextSharp.text.pdf.BaseFont.CP1252, iTextSharp.text.pdf.BaseFont.EMBEDDED);

      //  iTextSharp.text.Font font1 = new iTextSharp.text.Font("iTextSharp.text.Font", 10, Font.Bold);
      //FontFactory.GetFont("TIMES_ROMAN", 10, Font.Bold);

      iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 10);
      //iTextSharp.text.Font font = new iTextSharp.text.Font(9); 
      PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText, font));
      cell.BackgroundColor = new iTextSharp.text.Color(240, 240, 240);                                  
      pdfTable.AddCell(cell);
}

Upvotes: 1

Views: 4261

Answers (1)

Bruno Lowagie
Bruno Lowagie

Reputation: 77528

Change iTextSharp.text.pdf.BaseFont.TIMES_ROMAN to iTextSharp.text.pdf.BaseFont.TIMES_BOLD or use any of the other documented ways to use a bold font.

Upvotes: 1

Related Questions