我正在尝试将自定义字体设置为Paragraph,但我无法使其工作。 我尝试设置.Font =,但它只能在大小方面工作,但它忽略了字体。你能帮忙吗?
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);
答案 0 :(得分:13)
将其设置为the constructor:
Font contentFont = FontFactory.GetFont(…);
Paragraph para = new Paragraph(newTempLine, contentFont);
答案 1 :(得分:0)
检查以下是否有效:
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);