@AlexanderNovickov No, there is no way to create create a style separator using DOM.
In your code you add newly created Run
into the original paragraph, but it should be added to the paragraph created by db.InsertStyleSeparator()
. See the modified code:
db.InsertStyleSeparator();
db.ParagraphFormat.StyleName = "Normal";
Run r = new Run(docOriginal, "text");
db.CurrentParagraph.AppendChild(r);
Also, in your originaly attached document there is no style separator. There are simply two Run
nodes with different styles. You can recreate the same using Aspose.Words DOM using code like the following:
Document doc = new Document();
Style st1 = doc.Styles.Add(StyleType.Character, "st1");
Style st2 = doc.Styles.Add(StyleType.Character, "st2");
st2.Font.Bold = true;
Run run1 = new Run(doc, "This is the first run");
Run run2 = new Run(doc, "This is the second run");
run1.Font.Style = st1;
run2.Font.Style = st2;
doc.FirstSection.Body.FirstParagraph.AppendChild(run1);
doc.FirstSection.Body.FirstParagraph.AppendChild(run2);
doc.Save(@"C:\Temp\out.docx");