I cannot get the code to debug into the MyReplaceEvaluator class with this code.
Here is my code… the aspose.docx is an empty docx document with the string
"FIND MY COORDIANTES in it.
Can you tell me why ? Thx
class Program
{
static void Main(string[] args)
{
Document doc = new Document(@"C:\Temp\aspose.docx");
MyReplaceEvaluator myEval = new MyReplaceEvaluator();
FindReplaceOptions options = new FindReplaceOptions();
options.ReplacingCallback = myEval;
options.FindWholeWordsOnly = true;
doc.Range.Replace("FIND MY COORDIANTES", "replacement", options);
doc.Save(@"C:\Temp\out.docx");
}
private class MyReplaceEvaluator : IReplacingCallback
{
ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
{
DocumentBuilder builder = new
DocumentBuilder((Document)e.MatchNode.Document);
builder.MoveTo(e.MatchNode);
BookmarkStart start = builder.StartBookmark("temp");
builder.EndBookmark("temp");
LayoutCollector collector = new LayoutCollector((Document)e.MatchNode.Document);
LayoutEnumerator enumerator = new LayoutEnumerator((Document)e.MatchNode.Document);
enumerator.Current = collector.GetEntity(start);
Console.WriteLine("({0},{ 1})", enumerator.Rectangle.Left, enumerator.Rectangle.Top);
e.MatchNode.Document.Range.Bookmarks["temp"].Remove();
return ReplaceAction.Skip;
}
}
}
}