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

Free Support Forum - aspose.com

Finding coordinate of a string on pdf

Can Aspose.PDF determine the exact coordinates of a certain piece of text on a pdf page ?
How would I do that … Can you point me in the right direction.

Thanks

@nick1234

Thanks for contacting support.

You may extract text along with its Position (XIndent, YIndent) and Rectangle (LLX, LLY, URX, URY), by using TextFragmentAbsorber. Please check following code snippet, where I have determined the position of the text along with its rectangle.

Document doc1 = new Document(dataDir + "A.pdf");
TextFragmentAbsorber tfa = new TextFragmentAbsorber("Search Term");
doc1.Pages.Accept(tfa);
foreach (TextFragment tf in tfa.TextFragments)
{
 var position = tf.Position;
 var rectangle = tf.Rectangle;
}

In case you face any issue while implementing above code snippet, please share your source PDF document with us. We will test the scenario in our environment and address it accordingly.