Question

 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();

Can someone help me please

Was it helpful?

Solution

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);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top