Replacing of text

How i can i replace a text in a document specified in a range

for example i have <> need to replace it with aspose
<> is there in many pages need to replace it with aspose in only 2 pages.
then how can i do it ??

@mottosystems,

Thanks for your inquiry. In your case, we suggest you please implement IReplacingCallback interface. In IReplacingCallback.Replacing, check the page number of matched node and replace the text with the desired content. Please read the following article.
Find and Replace

The LayoutCollector.GetStartPageIndex method gets 1-based index of the page where the node begins. Please check the following code snippet. Hope this helps you.

public class FindandRepalceforSpecificPage : IReplacingCallback
{

    ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
    {
        // This is a Run node that contains either the beginning or the complete match.
        Node currentNode = e.MatchNode;
        LayoutCollector collector = new LayoutCollector((Document)currentNode);

        if (collector.GetEndPageIndex(currentNode) == 1 || collector.GetEndPageIndex(currentNode) == 2)
        {
                //Your code...
        }
                 

        return ReplaceAction.Skip;
    }
             
}

Thank for you reply @tahir.manzoor
If there is an occurance of <> two times in the same page but need to replace at only one instance and that instance will be decided dynamically then i think i cannot implement IReplacingCallback. can you please suggest me with another one

@mottosystems

Thanks for your inquiry. In this case, you also need to implement IReplacingCallback interface. Please declare a variable in class FindandRepalceforSpecificPage and use it in IReplacingCallback.Replacing. You can use the combination of page number and value of this variable to get the desired output. Please check the code example shared in following link.
Example 3: Use a Custom Evaluator

If you still face the problem, please ZIP and attach your input and expected output documents along with some detail of your use case. We will then provide you with more information about your query.