如何使用itextsharp / iText删除鼠标悬停在PDF链接注释的光标效果上?

问题描述 投票:1回答:1

我很难从pdf中删除带有文本样式的链接注释。

但是,我能够使用以下代码替换链接操作。

Annots = PageDictionary.GetAsArray(PdfName.ANNOTS);
if ((Annots == null) || (Annots.Length == 0))
{
  continue;
}
foreach (PdfObject A in Annots.ArrayList)
{
    PdfDictionary AnnotationDictionary = (PdfDictionary)PdfReader.GetPdfObject(A);

    if (!AnnotationDictionary.Get(PdfName.SUBTYPE).Equals(PdfName.LINK))
    {
      continue;
    }
    if (AnnotationDictionary.Get(PdfName.A) == null)
    {
        continue;
    }

    PdfDictionary AnnotationAction =(PdfDictionary)AnnotationDictionary.GetAsDict(PdfName.A);
    if (AnnotationAction.Get(PdfName.S).Equals(PdfName.URI))
    {
        AnnotationAction.Remove(PdfName.S);
        AnnotationAction.Remove(PdfName.URI);
        AnnotationAction.Put(PdfName.S, PdfName.GOTO);
    }
}

但鼠标悬停/点击效果和链接下划线仍然保持不变。

如何删除注释的所有链接文本样式和鼠标操作?

c# itext
1个回答
0
投票

应用这个我希望它会起作用

//  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);

    }
© www.soinside.com 2019 - 2024. All rights reserved.