Add the after and before blue color text of links to link annotation

Hi Team,
In attached pdf, where ever the blue text found, check the entire blue text has link, if not i have to add entire blue text to the existing link. could you please help me with the code i required.

Thanks,
Harish G.bluetext.pdf (17.6 KB)

@HarishGali

We are trying to prepare a sample code snippet for you and will get back to you shortly.

Thank you, I am eagerly waiting for the code snippet.

@HarishGali

This is a custom scenario and we are afraid that the API does not offer any direct method or the functionality to achieve your requirements. However, we are trying to come up with a workaround and will inform you as soon as we have some. Please give us little time.

Thank you asad, i request you to do ASAP.

@HarishGali

We tried to achieve your requirements using the code below but unfortunately, API was unable to recognize the text on color basis:

Document doc = new Document(dataDir + "bluetext.pdf");
foreach (Aspose.Pdf.Page page in doc.Pages)
{
 List<string> additionList = new List<string>();

 var AnnotationList = page.Annotations.Where(x => x.AnnotationType == AnnotationType.Link);
 if (AnnotationList.Any())
 {
  TextFragmentAbsorber textAbsorber = new TextFragmentAbsorber();
  page.Accept(textAbsorber);
  foreach(TextFragment fragment in textAbsorber.TextFragments)
  {
   if(fragment.TextState.ForegroundColor == Color.Blue)
   {
    foreach(var annot in AnnotationList)
    {
     if(fragment.Text.Contains(annot.Contents))
     {
      var link = annot.Hyperlink;
      var rect = fragment.Rectangle;

      page.Annotations.Delete(annot);

      LinkAnnotation linkannot = new LinkAnnotation(page, rect);
      linkannot.Hyperlink = link;
      page.Annotations.Add(linkannot);
     }
    }
   }
  }
 }
}
doc.Save(dataDir + "updated.pdf");

Therefore, a ticket as PDFNET-51986 has been logged in our issue tracking system to further investigate the issue. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Thank you for quick response. this works good, but one issue is if the blue text split into two text fragments, then there is disturbance in requirement.so, please try to give solution for this issue.

@HarishGali

It looks like the API is behaving differently on different machines. On our end, it was not able to recognize the text on the basis of color. Nevertheless, can you please share the output PDF generated at your end?

Hi ali,

please find first link in first page in attached document, the blue text split into two text fragments,

also annot.Contents showing empty always in my machine. unable to achieve the good output with that, could please give me the solution.

Thank you.bluetext3.pdf (76.9 KB)

@HarishGali

Another issue as PDFNET-52002 has been logged in our issue tracking system for this new case. We will definitely investigate it as well on first come first serve basis and let you know as soon as the ticket is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.

any solution??

@HarishGali

Please note that the tickets have recently been logged in our issue tracking system and they are pending for analysis. They will be investigated on first come first serve basis as per free support policies. Once they are completely investigated, we will be able to share some news about their fix ETA. Please give us some time.

We are sorry for the inconvenience.

its really emergency task,

could you please give me the solution for that.

@HarishGali

As mentioned earlier, please note that issues are resolved on first come first serve basis in free support model and resolution time of the issue depends upon the number of issues logged previously. Furthermore, we also offer paid support option for urgent issues. Issues in paid support model have highest priority and are resolved on urgent basis. You may please check and use this option in case issues are showstopper for you. We will further let you know once we have any updates.

We apologize for the inconvenience caused.