I am trying to Load a Form PDF using iTextsharp. When i tried to set the value for a field element in that PDF using Acrofield, am getting "Invalid Cast Exception". "Error Converting IDictionary Object type to Array".
We are using itextSharp 5.* version
Error Stack Trace :
Unable to cast object of type 'iTextSharp.text.pdf.PdfDictionary' to type 'iTextSharp.text.pdf.PdfArray'.
at iTextSharp.text.pdf.AcroFields.Fill()
at iTextSharp.text.pdf.AcroFields..ctor(PdfReader reader, PdfWriter writer)
at iTextSharp.text.pdf.PdfStamperImp.GetAcroFields()
at iTextSharp.text.pdf.PdfStamper.get_AcroFields()
at generate_PDF.WebForm1.generate_PDF() in c:\Users\Documents\Visual Studio 2013\Projects\generate_PDF\generate_PDF\PDF.aspx.cs:line 159
at generate_PDF.WebForm1.BtnPrint_Click(Object sender, EventArgs e) in c:\Users\465816\Documents\Visual Studio 2013\Projects\generate_PDF\generate_PDF\PDF.aspx.cs:line 32
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.
Please find the form in below Link as well.
https://drive.google.com/file/d/0B3W8aJry8ZMERnJubHpMdVk5SmM/view?usp=sharing
But the same code is working for other PDF form. Please Let me know the reason the reason for getting this Error, is this becasue of the PDF ? or any other issue.