Posted by a ceTe Software moderator
Hello,
In order to add the text with bold and bold italic style you will need to build respective font objects using bold and bold italic fonts then you will need to create FontFamily object using the font objects and add it to the FontFaces of the HtmlTextArea. Below is the sample code for it.
Document document = new Document();
Page page = new Page();
//Building font objects and FontFamily object.
TrueTypeFont verdanaRegularFont = new TrueTypeFont("verdana.TTF");
TrueTypeFont verdanaBoldFont = new TrueTypeFont("verdanab.TTF");
TrueTypeFont verdanaBoldItalicFont = new TrueTypeFont("verdanaz.TTF");
TrueTypeFont verdanaItalicFont = new TrueTypeFont("verdanai.TTF");
FontFamily verdanaFontFamily = new FontFamily("VerdanaFontFamily", verdanaRegularFont, verdanaBoldFont, verdanaItalicFont, verdanaBoldItalicFont);
string text = "<p><b>bold</b></p><p><b><i>bold and italic</i></b></p>";
HtmlTextArea htmlTextArea = new HtmlTextArea(text, 100, 100, 300, 200, verdanaFontFamily, 12, true);
htmlTextArea.FontFaces.Add(verdanaFontFamily);
page.Elements.Add(htmlTextArea);
document.Pages.Add(page);
document.Draw(@"C:\MyDocument_v3.pdf");
Thanks,
ceTe Software Support Team.