I need to create a pdf where some part of the string is bold and some is regular. For this I use the <b> and </b> tags in the text for a FormattedTextArea but this only works if I use ceTe.DynamicPDF.FontFamily.Times or any of the other fonts in ceTe.DynamicPDF.FontFamily.
If I create an OpenTypeFont, the tags are ignored. The code I am using is given below -
FormattedTextAreaStyle style = new FormattedTextAreaStyle(ceTe.DynamicPDF.FontFamily.Times, 10, true);
FormattedTextArea textArea = new FormattedTextArea("<b><i>Bold: </i></b> Regular", 0, 0, 100, 100, style);
textArea.Height = textArea.GetRequiredHeight();
System.Drawing.Font tempFont = new System.Drawing.Font("Microsoft Sans Serif", 10);
ceTe.DynamicPDF.Font ceTeFont = OpenTypeFont.LoadSystemFont(tempFont) as OpenTypeFont;
if (ceTeFont == null)
return;
ceTe.DynamicPDF.FontFamily fontFamily = new ceTe.DynamicPDF.FontFamily(ceTeFont.Name,
ceTeFont);
if (fontFamily == null)
return;
FormattedTextAreaStyle style1 = new FormattedTextAreaStyle(fontFamily, 10, true);
FormattedTextArea textArea1 = new FormattedTextArea("<b><i>Bold: </i></b> Regular", 0,
textArea.Height + 10, 100, 100, style1);
textArea1.Height = textArea1.GetRequiredHeight();
Document document = new Document();
Page page = new Page();
page.Elements.Add(textArea);
page.Elements.Add(textArea1);
document.Pages.Add(page);
string pdfFileName = @"c:\temp\test.pdf";
document.Draw(pdfFileName);