使用iTextSharp在pdf文件中查找超链接

Ash*_*ain 0 itext

我在此行中从PDF文件获取超链接时收到错误

PdfDictionary AnnotationAction = (PdfDictionary)AnnotationDictionary.Get(PdfName.A);
Run Code Online (Sandbox Code Playgroud)

下面提到异常,请有人帮忙。

无法将类型为“ iTextSharp.text.pdf.PRIndirectReference”的对象转换为类型为“ iTextSharp.text.pdf.PdfDictionary”的对象

mkl*_*mkl 5

代替

PdfDictionary AnnotationAction = (PdfDictionary)AnnotationDictionary.Get(PdfName.A);
Run Code Online (Sandbox Code Playgroud)

请试试

PdfDictionary AnnotationAction = AnnotationDictionary.GetAsDict(PdfName.A);
Run Code Online (Sandbox Code Playgroud)

对于您的文档,/ A键的值似乎不是立即作为字典,而是对字典的引用。此引用必须解决。GetAsDict做到这一点,并在幕后的演员。