I have a PDF form template that I fill from your C# code with values, to be printed out.
Suddenly, my customer reports errors - when trying to print the PDF (from an ASP.NET page), they get:
Unable to cast object of type 'iTextSharp.text.pdf.PdfName' to type 'iTextSharp.text.pdf.PdfIndirectReference'
When digging in my code, I discovered this error happens on this line of code here:
PdfReader reader = new PdfReader("MyPdfTemplateName.pdf");
PdfStamper stamper = new PdfStamper(reader, ms);
// filling field values here.....
stamper.FormFlattening = true; // **** EXCEPTION HERE *****
stamper.Writer.CloseStream = false;
stamper.Close();
The funny thing is: this only happens with the "new" version 5.0 of iTextSharp - I went back to my previous version 4.1.2, and with the exact same code, exact same PDF form, it works flawlessly.....
Anyone have any idea or insight as to why the new v5 of iTextSharp behaves this way??