public static void ShowLinkAnnotations(Page page)
{
foreach (Aspose.Pdf.Annotations.Annotation annot in page.Annotations)
{
if (annot is LinkAnnotation)
{
// Print the URL of each Link Annotation
Console.WriteLine("URI: " + ((annot as LinkAnnotation).Action as GoToURIAction).URI);
TextAbsorber absorber = new TextAbsorber();
absorber.TextSearchOptions.LimitToPageBounds = true;
absorber.TextSearchOptions.Rectangle = annot.Rect;
page.Accept(absorber);
string extractedText = absorber.Text;
// Print the text associated with hyperlink
Console.WriteLine(extractedText);
}
}
}
// ExEnd:ShowLinkAnnotations