Aspose PDF for .NET如何删除pdf文件中的超链接?

我使用代码如下:

        Document document = new Document(@"C:\Users\Test181.pdf");

        Page page = document.Pages[1];

        AnnotationSelector selector = new AnnotationSelector(new LinkAnnotation(page, Aspose.Pdf.Rectangle.Trivial));

        page.Accept(selector);

        page.Annotations.Delete();

        document.Save(@"C:\Users\Remove_out.pdf");

但是无法删除pdf文件中的文字超链接,问题pdf和截图请看附件,谢谢!
Test181.pdf (186.2 KB)
picture.png (18.8 KB)

@howze,

您是否可以尝试使用下面的示例代码,如果仍有问题,请与我们分享反馈。此代码将帮助您实现要求。

// load the PDF file
Document doc = new Document(dataDir + “Test embedded hyperlink.docx.pdf”);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("");
int pageNum = 1;
//accept the absorber for first page
Page page = doc.Pages[pageNum];
page.Accept(textFragmentAbsorber);
//get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
//loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
{
LinkAnnotation linkAnnot = new LinkAnnotation(page, textFragment.Rectangle);
linkAnnot.Border = (new Border(linkAnnot));
linkAnnot.Border.Width = (0);
page.Annotations.Add(linkAnnot);
}
doc.Save(dataDir + “HyperlinkRemoved_output_19.5.pdf”);

@Adnan.Ahmad
感谢回复
但是您提供的代码依然无法删除超链接
你们自己使用以上代码可以成功删除我的超链接吗?

@howze,

我已观察到您提到的问题并将其记录为 PDFNET-47972 在我们的问题跟踪系统中。我们将进一步调查该问题的详细信息,并向您发布其纠正状态。请耐心等待,为我们节省时间。

对此造成的不便,我们表示歉意。