Reputation: 7798
I am trying to set custom font to Paragraph, but I can't make it work. I tried setting .Font= , but it only works size-wise, but it ignores font. Could you please assist?
Paragraph T = new Paragraph(newTempLine);
iTextSharp.text.Font contentFont = iTextSharp.text.FontFactory.GetFont("Webdings", 12, iTextSharp.text.Font.NORMAL);
T.Font = contentFont;
myDocument.Add(T);
Upvotes: 11
Views: 18341
Reputation: 2832
Check if below works:
string name = "Century Gothic Bold";
if (!FontFactory.IsRegistered(name))
{
string systemRoot = Environment.GetEnvironmentVariable("SystemRoot");
string path = Path.Combine(systemRoot, "fonts", @"GOTHICB.TTF");
FontFactory.Register(path);
}
var font = FontFactory.GetFont(name, fontSize, textColor);
var paragraph = new Paragraph(text, font);
Phrase phrase = new Phrase(paragraph);
var myPdfCell = new PdfPCell(phrase);
Upvotes: 0
Reputation: 39990
Set it in the constructor:
Font contentFont = FontFactory.GetFont(…);
Paragraph para = new Paragraph(newTempLine, contentFont);
Upvotes: 13