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)