Range.replace issue

I am using the following code to find an expression & replace it with a string.
I am using the following code, and there are 2 things happening

  • either I receive the error "Object reference not set to an instance of an object. "
  • or it goes through the ReplaceHandler numerous times, when the expression being replaced is only in there once.
Regex regex = new Regex(@"[PlaceHolder]");
WorkDocClone.Range.Replace(regex, new ReplaceEvaluator(ReplaceHandler), false);
private ReplaceAction ReplaceHandler(object sender, ReplaceEvaluatorArgs e)
{
    DocumentBuilder DB = new DocumentBuilder((Document) e.MatchNode.Document);
    DB.MoveTo(e.MatchNode);
    DB.StartBookmark("Addressee");
    DB.EndBookmark("Addressee");
    DB.MoveToBookmark("Addressee", true, true);
    DB.Font.ClearFormatting();
    DB.Writeln(_ESignAddressees);
    return ReplaceAction.Replace;
}

Hi

Thanks for your request. I think in this case you should use the same technique as demonstrated in the following thread:
https://forum.aspose.com/t/86236
If you need more assistance, I will be glad to help you.
Best regards,