Itextsharp set font for IElement

后端 未结 1 410
 var htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmlText), styles);

                document.Open();


BaseFont Vn_Helvetica = BaseFont.CreateFont(@\"C         


        
1条回答
  •  天命终不由人
    2021-01-13 05:14

    You can use a font in iTextSharp using

    FontFactory.RegisterDirectories();
    Font fontNormal = new Font(FontFactory.GetFont("Arial", 12, Font.NORMAL))
    

    You should be able to set the font on a paragraph using the following:

    foreach (var t in htmlarraylist)
    {
        if(t is Paragraph)
        {
            ((Paragraph)t).Font = fontNormal;
        }
        document.Add((IElement)t);
    }
    

    0 讨论(0)
提交回复
热议问题