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

Free Support Forum - aspose.com

X,y coordinates of a specific text in word document


I need to get (x,y) coordinates of a particular text in word document.
Can any one help


Thanks for your inquiry. You can achieve your requirement by searching the specific text, move cursor to the matched text, insert a bookmark and get bookmark coordinates. Please check following documentation links and sample code snippet for the purpose.

Find and Replace
Aspose.Words.Layout Namespace (see LayoutEnumerator.Rectangle property)

Document doc = new Document(@"C:\Temp\input.docx");
doc.Range.Replace(new Regex("FIND MY COORDIANTES"), new MyReplaceEvaluator(), true);
private class MyReplaceEvaluator : IReplacingCallback


ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)


DocumentBuilder builder = new DocumentBuilder((Document)e.MatchNode.Document);


BookmarkStart start = builder.StartBookmark("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);


return ReplaceAction.Skip;