We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unable to Debug class Implementing IReplacingCallback

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;

        }

    }


}

}

@nick1234,

Thanks for your inquiry. To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your input Word document
  • Please create a standalone console application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start further investigation into your issue and provide you more information. Thanks for your cooperation.

Best regards,