The following code is from this link with a slight modification https://docs.aspose.com/words/net/working-with-paragraphs/#inserting-style-separator-to-put-different-paragraph-styles.
The change was to insert a section (continuous) just before adding the text. Note when running the code the style separator does not show in the output, in other words, there is only one style applied on the paragraph, the “MyParaStyle”.
Is this correct?
Thanks!
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
var doc = new Words.Document();
var builder = new Words.DocumentBuilder(doc);
// following 3 lines added to example
var section = new Words.Section(doc);
section.PageSetup.SectionStart = Words.SectionStart.Continuous;
doc.Sections.Add(section);
Words.Style paraStyle = builder.Document.Styles.Add(Words.StyleType.Paragraph, "MyParaStyle");
paraStyle.Font.Bold = false;
paraStyle.Font.Size = 38;
paraStyle.Font.Name = "Arial";
// Append text with "Heading 1" style.
builder.ParagraphFormat.StyleIdentifier = Words.StyleIdentifier.Heading1;
builder.Write("Heading 1");
builder.InsertStyleSeparator();
// Append text with another style.
builder.ParagraphFormat.StyleName = paraStyle.Name;
builder.Write("This is text with some other formatting ");
// Save the document to disk.
doc.Save($@"c:\temp\{Guid.NewGuid()}.docx");