Aspose-pdf 18.6 版本 向pdf内插入无动作超链接

现在想向pdf内插入一个无动作的超链接。现在插入不进去,希望可以帮帮忙。
image.png (78.2 KB)
a.pdf (56.2 KB)

@guopeng

您可以使用以下代码段创建没有链接操作的链接注释:

var textFragmentAbsorber = new TextFragmentAbsorber(@"zhi");
var textSearchOptions = new TextSearchOptions(true);
textFragmentAbsorber.TextSearchOptions = textSearchOptions;
Document pdfDocument = new Document(dataDir + "a.pdf");
pdfDocument.Pages.Accept(textFragmentAbsorber);
var textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
 LinkAnnotation linkAnnotation = new LinkAnnotation(textFragment.Page, textFragment.Rectangle);
 Border border = new Border(linkAnnotation);
 border.Width = 0;
 linkAnnotation.Border = border;
 textFragment.Page.Annotations.Add(linkAnnotation);
}
pdfDocument.Save(dataDir + "test20.6.out.pdf");