FontStyleName Property |
Namespace: Aspose.Words
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert text with two styles that will be replaced by another style builder.Font.StyleIdentifier = StyleIdentifier.Emphasis; builder.Writeln("Text originally in \"Emphasis\" style"); builder.Font.StyleIdentifier = StyleIdentifier.IntenseEmphasis; builder.Writeln("Text originally in \"Intense Emphasis\" style"); // Loop through every run node foreach (Run run in doc.GetChildNodes(NodeType.Run, true).OfType<Run>()) { // If the run's text is of the "Emphasis" style, referenced by name, change the style to "Strong" if (run.Font.StyleName.Equals("Emphasis")) run.Font.StyleName = "Strong"; // If the run's text style is "Intense Emphasis", change it to "Strong" also, but this time reference using a StyleIdentifier if (run.Font.StyleIdentifier.Equals(StyleIdentifier.IntenseEmphasis)) run.Font.StyleIdentifier = StyleIdentifier.Strong; } doc.Save(ArtifactsDir + "Font.ChangeStyle.docx");