I want to use iTextSharp to write some text. I\'m using this method:
var font = BaseFont.CreateFont(BaseFont.TIMES_BOLD, BaseFont.WINANSI, BaseFont.EMBEDDED)
Im posting this since someone else might find this useful. I had a similar problem when i ran my code on server. The reason being itextsharp could not find the font style in OS. My PDF showed some random font style when it could not find the font(dint throw error). I copied the required font files (.ttf) to my project bin folder and used following code.
public static BaseFont GetFont(string fontName)
{
return BaseFont.CreateFont(HttpContext.Current.Server.MapPath("~/Bin/" + fontName + ".ttf"), BaseFont.CP1252, BaseFont.EMBEDDED);
}
Here i get the desired font
`BaseFont sm = GetFont("comic"); //The fontName here should exactly match` the` file name in bin folder