How to replace a text with a link

I am getting an exception when running this code:
Document pdfDocument = new Document(_dataDir + “test.pdf”);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(“Test”);
TextSearchOptions textSearchOptions = new TextSearchOptions(true);
textFragmentAbsorber.TextSearchOptions = textSearchOptions;

            foreach (Page page in pdfDocument.Pages)
            {
                page.Accept(textFragmentAbsorber);
                TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

                foreach (TextFragment textFragment in textFragmentCollection)
                {
                    textFragment.Text = "REPLACED";
                    LinkAnnotation link = new LinkAnnotation(page, textFragment.Rectangle);
                    Border border = new Border(link);
                    border.Width = 0;
                    link.Border = border;
                    //link.Action = new GoToURIAction("\\audiofiles\\audio.mp3");
                    link.Action = new GoToURIAction("www.aspose.com");
                    page.Annotations.Add(link);
                    page.Annotations.Add(link);
                }
            }
            pdfDocument.Save(_dataDir + "Replaced_19.6.pdf");

test.pdf (16.8 KB)

@vaclavj

Have you tried using the latest version of the API? Also, please make sure that you use a valid or 30-days free temporary license while using the API. We tested in our environment and could not reproduce any Exceptions. Please check the attached output for your kind reference.
Replaced_23.8.pdf (90.9 KB)

A post was split to a new topic: Could not retrieve the 30-day license key