TextFragment doesn't exist Hyperlink

Hello. I have a problem with TextFragment. I find TextFragment with Rectangle and set a hyperlink to it. When I find this TextFragment in the second time the hyperlink doesn’t exist. The rectangle is the same in the both cases. Please, help me.

@VladimirFedorchenko

Thank you for contacting support.

Would you please share a narrowed down code snippet along with source and generated files so that we may investigate to help you out. Before sharing requested data, please ensure using Aspose.PDF for .NET 19.1 in your environment.

Ok. You can use any PDF document. First, you must find TextFragment with rectangles. Then you set the hyperlink to this fragment and save the document:
fragment.Hyperlink = new WebHyperlink(“https://www.google.com”);
When I open the document in the second time and find the same(!) TextFragment the hyperlink that I set earlier are null. But I wanna see the hyperlink, that I set before.
Please, help me. Sorry, that I can’t give you a test example.

@VladimirFedorchenko

Would you please verify if you are using the code snippet like below, to achieve your requirements so that we may investigate further to help you out.

// Open document
Document pdfDocument = new Document(dataDir + "Test.pdf");
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();
textFragmentAbsorber.TextSearchOptions.Rectangle = new Aspose.Pdf.Rectangle(93, 510, 341, 522);

Page page = pdfDocument.Pages[1];
// Accept the absorber for first page
page.Accept(textFragmentAbsorber);

foreach (TextFragment fragment in textFragmentAbsorber.TextFragments)
{
    fragment.Hyperlink = new WebHyperlink("https://www.aspose.com");
}
pdfDocument.Save(dataDir + "Hyperlink_19.1.pdf");

Yes, I use the code like that for adding hyperlinks and removing them, but when I try to remove it the hyperlink doesn’t exist.

@VladimirFedorchenko

We are afraid we need exact SSCCE code from you instead of somewhat similar code created by us. Therefore, kindly share requested code snippet so that we may proceed to reproduce it and assist you efficiently.

I have list of points. Here is my code. It is for adding a hyperlink. When I try to find this fragment in the second time the hyperlink is null.
List<Aspose.Pdf.Rectangle> rectangles = new List<Aspose.Pdf.Rectangle>();
for (int i = 0; i < points.Count; i += 4)
{
rectangles.Add(new Aspose.Pdf.Rectangle(points[i].X, points[i].Y, points[i + 3].X, points[i + 3].Y));
}
foreach (Aspose.Pdf.Rectangle rectangle in rectangles)
{
TextFragmentAbsorber absorber = new TextFragmentAbsorber();
absorber.TextSearchOptions = new TextSearchOptions(rectangle);
pdf.Pages[annotation.PageNumber].Accept(absorber);
foreach (TextFragment fragment in absorber.TextFragments)
fragment.Hyperlink = new WebHyperlink(“https://www.google.com”);
}

@VladimirFedorchenko

Thank you for elaborating it further.

Would you please try to Add Hyperlink in a PDF File as explained in linked article, and then share your kind feedback with us.

Thank you. I have solved my problem.

@VladimirFedorchenko

Thank you for your kind feedback.

We are glad to know that your problem has been resolved. Please keep using our API and in event of any further query, feel free to ask.