C# 如何使用iText从PDF中删除链接批注?

C# 如何使用iText从PDF中删除链接批注?,c#,itextsharp,C#,Itextsharp,在这里,我想使用iTextSharp从PDF中永久删除注释(链接、文本等) 我已经试过了 AnnotationDictionary.Remove(PdfName.LINK); 但该链接注释存在于该PDF中 注意: //Get the current page PageDictionary = R.GetPageN(i); //Get all of the annotations for the current page Annots = PageDictionary.GetAsArray(P

在这里,我想使用iTextSharp从PDF中永久删除注释(链接、文本等)

我已经试过了

AnnotationDictionary.Remove(PdfName.LINK);
但该链接注释存在于该PDF中

注意:

//Get the current page
PageDictionary = R.GetPageN(i);

//Get all of the annotations for the current page
Annots = PageDictionary.GetAsArray(PdfName.ANNOTS);

foreach (PdfObject A in Annots.ArrayList)
{
//code to check the annotation 

//remove the annotation
Annots.Remove(int idx);

}
我想删除特定的选定注释(链接、文本等),
例如,我想删除URI为www.google.com的链接注释,其余的链接注释我想保留为exist。

我得到了问题的答案

示例代码:

//Get the current page
PageDictionary = R.GetPageN(i);

//Get all of the annotations for the current page
Annots = PageDictionary.GetAsArray(PdfName.ANNOTS);

foreach (PdfObject A in Annots.ArrayList)
{
//code to check the annotation 

//remove the annotation
Annots.Remove(int idx);

}

请下载RUP并查看PDF的内部结构。您不需要删除
链接
条目,您需要删除包含
链接的完整注释词典
!你会在这里找到鲁普斯:是的,我明白,这只是我来问的。如何从PDF文件中完全删除一个批注?通过使用iTextSharpYa,我得到了问题的答案。你的链接很有用,我对你的答案投了赞成票。在过去的两个小时里,我参加了一个会议,所以我自己没有时间写一个片段,但我很高兴看到我的指针起到了作用。当然,欢迎你,我需要你这样的人支持来学习、发展和讨论我们的知识。感谢您的指导。在清空
注释后,如何保存pdf?似乎
R
是一个pdf阅读器,我在这里没有看到
PDFStamper
PDFWriter
,你能添加保存的代码吗?欢迎来到StackOverflow。这个答案应该通过添加一个关于代码正在做什么的描述,或者解释这个解决方案的工作原理来改进。