Using JoinRunsWithSameFormatting Code Index Error


When converting Word document to pdf, we do the replace operation. However, the “xxx” code you suggested to us previously caused an index error.

The sample project is (9.3 MB)


Thanks for your inquiry. Please use FindReplaceOptions.Direction property as Backward to fix this issue. Hope this helps you.

public static void ReplaceWithEvaluator(Aspose.Words.Document wordDoc, string OldValue, string NewValue, bool withLanguage)
    ReplaceEval myReplaceEval = new ReplaceEval();
    myReplaceEval.ReplaceText = NewValue.Replace("\n", "");
    myReplaceEval.WithLang = withLanguage;
    myReplaceEval.OldValue = OldValue;
    FindReplaceOptions options = new FindReplaceOptions();
    options.ReplacingCallback = myReplaceEval;
    options.Direction = FindReplaceDirection.Backward;
    wordDoc.Range.Replace(new System.Text.RegularExpressions.Regex(@"\<" + OldValue + @"\>"), "", options);

Thanks for your answer. The problem has improved, but can this cause another error?


Thanks for your inquiry. No, this will not cause any issue. Please let us know if you have any more queries.