Set font for all text from Pdfptable with Itextsharp

Alex picture Alex · Jul 20, 2012 · Viewed 11.4k times · Source
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)
                {
                    if (t is PdfPTable)
                    {                          
                       //how set fontNormal all text from Pdfptable ?
                    }

                    document.Add((IElement)t);

                }

                    document.Close();

Can someone help me please

Answer

HatSoft picture HatSoft · Jul 20, 2012

Please try by setting font to the PdfPTable.DefaultCell property in you foreach loop

Example:
t.DefaultCell.Phrase = new Phrase() { Font = fontNormal };