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

Free Support Forum - aspose.com

Get a link annotation text

How to get a link annotation text from existing pdf. I have Link annotation

Hi Srini,


Thanks for your inquiry. You may find rectangle of linkannotation and find text from that particular page region using TextAbsorber class. Please check sample code as following. Hopefully it will help you to accomplish the task.

Document pdfDocument = new Document(myDir

  • “input.pdf”);<o:p></o:p>

foreach (Page aPage in pdfDocument.Pages)

{

foreach (Aspose.Pdf.InteractiveFeatures.Annotations.Annotation anAnnotation in aPage.Annotations)

{

if (anAnnotation is LinkAnnotation)

{

LinkAnnotation linkAnno = (LinkAnnotation)anAnnotation;

// create TextAbsorber object to extract text

Aspose.Pdf.Rectangle rect = linkAnno.Rect;

// create TextAbsorber object to extract text

TextAbsorber absorber = new TextAbsorber();

absorber.TextSearchOptions.LimitToPageBounds = true;

absorber.TextSearchOptions.Rectangle = rect;

// accept the absorber for first page

aPage.Accept(absorber);

// get the extracted text

string extractedText = absorber.Text;

Console.Out.WriteLine(extractedText);

}

}

}

pdfDocument.Dispose();

Please feel free to contact us for any further assistance.


Best Regards,