Please see the below conversion and correct me:

dynamic AnnotationAction = (PdfDictionary)AnnotationDictionary.Get(PdfName.A);

It's showing the following error:

"Cannot convert type 'iTextSharp.text.pdf.PRIndirectReference' to 'iTextSharp.text.pdf.PdfDictionary"

有帮助吗?

解决方案

You need to change your code like this:

dynamic AnnotationAction = AnnotationDictionary.GetAsDict(PdfName.A);

You are assuming that the dictionary is added as a direct object. It's not. It's stored inside the PDF as an indirect object and you are retrieving a reference to that object instead of the actual object. This is explained in this book: http://itextpdf.com/pdfabc

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top