Question

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"

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top