C# 更改itextsharp中的文本样式
我想使用itextsharp使字体加粗。下面是我的代码C# 更改itextsharp中的文本样式,c#,itextsharp,C#,Itextsharp,我想使用itextsharp使字体加粗。下面是我的代码 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,
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);
}
将
iTextSharp.text.pdf.BaseFont.TIMES_-ROMAN
更改为iTextSharp.text.pdf.BaseFont.TIMES_-BOLD
,或使用任何其他有文档记录的方式使用粗体字体