Some formatting objects like Font or ParagraphFormat support styles. A single built-in or user defined style is represented by a Style object that contains the corresponding style properties like name, base style, font and paragraph formatting of the style, and so on.
Furthermore, a Style object provides the StyleIdentifier property that returns a locale-independent style identifier represented by a StyleIdentifier enumeration value. The point is that the names of built-in styles in Microsoft Word are localized for different languages. Using a style identifier, you can find the correct style regardless of the document language. The enumeration values correspond to the Microsoft Word built-in styles such as Normal, Heading 1, Heading 2 etc. All user-defined styles are assigned the StyleIdentifier.User value.
Example DocumentBuilderApplyParagraphStyle
Shows how to apply a paragraph style.
[C#]
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set paragraph style
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
builder.Write("Hello");
[Visual Basic]
Dim doc As Document = New Document()
Dim builder As DocumentBuilder = New DocumentBuilder(doc)
' Set paragraph style
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title
builder.Write("Hello")
[Java]
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set paragraph style
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.TITLE);
builder.write("Hello");