Posted by a ceTe Software moderator
Hello Yashwant,
You can add superscript and subscript to the PDF document using <sup> and <sub> HTML tags and you will need to add the HTML text to the PDF document using FormattedTextArea. Also you can use Unicode values to add superscript and subscript. You will need to make sure that the font file which you are using has support for the Unicode value which you are using. Below is the sample code to add superscript and subscript using HTML tags and Unicode values.
Document document = new Document();
Page page = new Page();
OpenTypeFont font = new OpenTypeFont(@"ARIALUNI.TTF");
FontFamily family = new FontFamily("ArialFont", font);
//Adding superscript and subscript using HTML tags.
string str1 = "<p>X <sub>n</sub></p>" + "<p>E=mc<sup> <font pointSize='8'>2</font></sup></p> ";
FormattedTextArea area = new FormattedTextArea(str1, 100, 100, 200, 200, family, 14, true);
//Adding superscript and subscript using Unicode values.
string myText2 = "E=mc\u00B2 and X\u2080";
TextArea textArea = new TextArea(myText2, 100, 300, 100, 40, font, 12, RgbColor.Blue);
page.Elements.Add(area);
page.Elements.Add(textArea);
document.Pages.Add(page);
document.Draw(@"C:\MyDocument.pdf");
Thanks,
ceTe Software Support Team.