Thanks for your inquiry.
Please note that formatting is
applied on a few different levels. For example, let’s consider
formatting of simple text. Text in documents is represented by Run
element and a Run can only be a child of a Paragraph. You can apply
- to Run nodes by using Character Styles e.g. a Glyph Style
- to the parent of those Run nodes i.e. a Paragraph node (possibly via paragraph Styles)
- you can also apply direct formatting to Run nodes by using Run attributes (Font). In this case the Run will inherit formatting of Paragraph Style, a Glyph Style and then direct formatting.
A field in a Word document is a complex structure consisting of multiple nodes that include field start, field code, field separator, field result and field end. The Start, Separator and End properties point to the field start, separator and end nodes of the field respectively. The content between the field start and separator is the field code. The content between the field separator and field end is the field result.
To get the Font.StyleName of mail merge field, you can use following code snippet. Hope this helps you. Please let us know if you have any more queries.
Document doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToMergeField("test", false, false);
FieldStart fStart = (FieldStart)builder.CurrentNode;
Run run = (Run)builder.CurrentNode.NextSibling.NextSibling;