Domanda

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"

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top