DocumentBuilderInsertStyleSeparator Method

Inserts style separator into the document.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.2
public void InsertStyleSeparator()
This method allows to apply different paragraph styles to two different parts of a text line.
Shows how to separate styles from two different paragraphs used in one logical printed paragraph.
DocumentBuilder builder = new DocumentBuilder(new Document());

Style paraStyle = builder.Document.Styles.Add(StyleType.Paragraph, "MyParaStyle");
paraStyle.Font.Bold = false;
paraStyle.Font.Size = 8;
paraStyle.Font.Name = "Arial";

// Append text with "Heading 1" style
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
builder.Write("Heading 1");

// Append text with another style
builder.ParagraphFormat.StyleName = paraStyle.Name;
builder.Write("This is text with some other formatting ");
Shows how to use and separate multiple styles in a paragraph
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Write("This text is in the default style. ");


// Create a custom style
Style myStyle = builder.Document.Styles.Add(StyleType.Paragraph, "MyStyle");
myStyle.Font.Size = 14;
myStyle.Font.Name = "Courier New";
myStyle.Font.Color = Color.Blue;

// Append text with custom style
builder.ParagraphFormat.StyleName = myStyle.Name;
builder.Write("This is text in the same paragraph but with my custom style.");

doc.Save(ArtifactsDir + "DocumentBuilder.StyleSeparator.docx");
See Also