Click on LinkAnnotation and I want to open specific file in EmbededFiles.
Document doc = new Document(filePath);
FileStream fileStream = null;
string[] filePaths = Directory.GetFiles(rootPath);
foreach (string item in filePaths)
{
fileStream = new FileStream(item, FileMode.Open);
doc.EmbeddedFiles.Add(new FileSpecification(fileStream, Path.GetFileName(item)));
}
TextFragmentAbsorber absorber = new TextFragmentAbsorber(pattern, new TextSearchOptions(true));
doc.Pages.Accept(absorber);
TextFragmentCollection textFragmentCollection = absorber.TextFragments;
LinkAnnotation linkAnnotation = null;
foreach (TextFragment item in textFragmentCollection)
{
item.TextState.BackgroundColor = Aspose.Pdf.Color.Yellow;
linkAnnotation = new LinkAnnotation(item.Page, item.Rectangle);
linkAnnotation.Action = new LaunchAction(doc, item.Text);
**It doesn't work. What should I do?**
item.Page.Annotations.Add(fileAnnotation);
}
doc.Save(filePath, SaveFormat.Pdf);