0

In my WPF C# project I'm using docX library to create word documents. With this .NET library I could create String and add inside a docx file as Paragraph. My docx needs to have some subscript characters, for example:

Fb (b as subscript)

I know that there are Unicode characters and numbers for subscript, but some chars are not included. So, how can I add that subscript chars in a C# String?

FrancescoDS
  • 1,077
  • 4
  • 21
  • 55
  • Why don't you format (as in text formatting) the subscript text with the appropriate methods? Seems better than using a specific subscript character. – Lawliet Mar 09 '15 at 11:33

1 Answers1

3

According to this How to write text as Subscript? DocX forum post, you need to create a new Novacode.Formatting object. From the linked page:

You need to create a new formatting and assign the values you want to the font.

Dim fotext As New Novacode.Formatting

fotext.Script = Script.subscript

p.InsertText("Text here", False,fotext)

p being the paragraph that you're wanting to insert text into.

In C#, that would be something like this:

Novacode.Formatting fotext = new Novacode.Formatting();
fotext.Script = Script.subscript;
p.InsertText("Text here", false, fotext);
Sheridan
  • 68,826
  • 24
  • 143
  • 183