var htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmlText), styles);
document.Open();
BaseFont Vn_Helvetica = BaseFont.CreateFont(@"C:\Windows\Fonts\arial.ttf",
"Identity-H", BaseFont.EMBEDDED);
Font fontNormal = new Font(Vn_Helvetica, 12, Font.NORMAL);
foreach (var t in htmlarraylist)
{
document.Add((IElement)t);
//how set FontNormal if element is Paragraph?
}
document.Close();
有人可以帮助我吗
答案 0 :(得分:10)
您可以使用
在iTextSharp中使用字体FontFactory.RegisterDirectories();
Font fontNormal = new Font(FontFactory.GetFont("Arial", 12, Font.NORMAL))
您应该可以使用以下内容在段落上设置字体:
foreach (var t in htmlarraylist)
{
if(t is Paragraph)
{
((Paragraph)t).Font = fontNormal;
}
document.Add((IElement)t);
}