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

Free Support Forum - aspose.com

Get link text and color in PDF document using Aspose.PDF for .NET - Performance issue with large data

Hi Aspose,

Is there any way to get both link text and color with one time visit or Accept to TextFragmentAbsorber or TextAbsorber.
Reason: When we run on 50000 plus links using below 1 and 2 code to get link text and color. its giving an performance issue.

  1. We are using below code to get link text as
    Aspose.Pdf.Text.TextAbsorber absorber = new Aspose.Pdf.Text.TextAbsorber();
    Aspose.Pdf.Rectangle newRect = rect;
    LinkText = absorber.Text;

  2. We are using below code to get link text color
    Aspose.Pdf.Text.TextFragmentAbsorber textFragmentAbsorbernew = new Aspose.Pdf.Text.TextFragmentAbsorber();
    textFragmentAbsorbernew.TextSearchOptions = new Aspose.Pdf.Text.TextSearchOptions(newRect);
    int FragmentTextlength = 0;
    foreach (Aspose.Pdf.Text.TextFragment TextFrag in textFragmentAbsorbernew.TextFragments)
    if (FragmentTextlength < TextFrag.Text.Length)
    TextColor = TextFrag.TextState.ForegroundColor.ToString();
    FragmentTextlength = TextFrag.Text.Length;


Thanks for contacting support.

Would you kindly share a sample PDF along with the time information which is taken by the API in your environment while extracting required information. We will test the scenario in our environment and address it accordingly.

That’s fine.
I am just asking, it is any other way to fetch link text and color in one shot. If you have, please send the code snip set.


You can also extract links from PDF document using Annotations if they are added as LinkAnnotation in the PDF. Furthermore, please note that text/content extraction from PDF is a time taking procedure and the performance of the API may vary in case of different PDF documents due to their different structures and complexities. Which was why we requested for a sample PDF so that we can test it in our environment and address the issue if there is any.