@mjagatha,
Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for Java 17.10 with following code example. We have not found any issue with output document. Please use Aspose.Words for Java 17.10. We have attached the output document with this post for your kind reference.
output.zip (3.4 KB)
Document doc = new Document(MyDir + "109500_Default_2730_110513113604012.rtf");
for (Node node : doc.getChildNodes(NodeType.RUN, true).toArray()) {
Run run = (Run)node;
if (run.getFont().getBold() && run.getFont().getItalic()) {
String match = "";
match = run.getRange().getText();
int x = run.getRange().replace(match, "\\ZHI\\" + match+"\\N\\", new FindReplaceOptions());
System.out.println("Italic and bold replaced "+x);
}
if(run.getFont().getBold() && !run.getFont().getItalic())
{
String match= run.getText();
int x = run.getRange().replace(match, "\\H\\"+ match+"\\N\\", new FindReplaceOptions());
System.out.println(" bold stmt replaced "+x);
}
if(!run.getFont().getBold() && run.getFont().getItalic()){
String match= run.getText();
match = run.getText();
int x = run.getRange().replace(match, "\\ZI\\" + match+"\\N\\", new FindReplaceOptions());
System.out.println("Italic stmt replaced "+x);
}
}
doc.save(MyDir + "output.txt");