Draw rectangle, circle around text

Hi ,
I am evaluating ASPOSE.PDF product. I need to draw hollow rectangle/circle i.e. rectangle/circle with red borders around text on a page in PDF document. The text can be work or an entire row on document.
Can not get any way how to do it. Tried to use SearchTextAndDrawRectangle function in example project but it does not works.
Can you please suggest

@asif.khan

Thanks for contacting support.

Please use following code snippet in order to add/draw Circle around found text inside PDF document. For your reference, I have attached a sample PDF as well.

Document doc = new Document();
doc.Pages.Add();
Page pg = doc.Pages[1];
var tf = new TextFragment("some text on page");
pg.Paragraphs.Add(tf);

doc.Save(dataDir + "RectangleGraph.pdf");
doc = new Document(dataDir + "RectangleGraph.pdf");
Page page = doc.Pages[1];

TextFragmentAbsorber textAbsorber = new TextFragmentAbsorber(@"page");
doc.Pages[1].Accept(textAbsorber);

tf = textAbsorber.TextFragments[1];

var canvas = new Drawing.Graph((float)page.PageInfo.Width, (float)page.PageInfo.Height);
page.Paragraphs.Add(canvas);
Aspose.Pdf.Drawing.Ellipse circle = new Drawing.Ellipse(tf.Rectangle.ToRect().Left - (float)page.PageInfo.Margin.Left - 3, tf.Rectangle.ToRect().Bottom + (float)page.PageInfo.Margin.Bottom - (float)tf.Rectangle.Height - 3, (float)tf.Rectangle.Width + 5, (float)tf.Rectangle.Height + 5);

var c = ColorTranslator.FromHtml("#FFFF00");
circle.GraphInfo.Color = Aspose.Pdf.Color.FromRgb(c);
canvas.Shapes.Add(circle);
doc.Save(dataDir + "CircleGraph.pdf");

CircleGraph.pdf (2.3 KB)

You will notice in the output and code snippet that I have drawn ellipse instead of circle because, the ellipse will properly encircle the text or entire row as compared to circle. In case of any further assistance, please feel free to let us know.

PS: For rectangle, I have shared the code snippet and respective output in your other post.