Fill AcroForms

Jun 8, 2010 at 12:12 AM

I am having an issue trying to Fill form fields.  I was getting the following error

Constructor on type 'PdfSharp.Pdf.AcroForms.PdfAcroForm' not found.

A little background.  I am trying to bundle the acrobat form in the resources so I am reading the form in from the resources using Application.GetResourceStream, then using PdfReader.Open with the stream.

Looking into the source it appears as there is no public constructor for the AcroForm object.  There are 2 internal contstructors overloads.  The error is happening on the Activator.CreateInstance. so I changed the constructor to public.

Doing that gives me the following error

Attempt by method 'PdfSharp.Pdf.PdfDictionary+DictionaryElements.CreateArray(System.Type, PdfSharp.Pdf.PdfArray)' to access method 'PdfSharp.Pdf.AcroForms.PdfAcroField+PdfAcroFieldCollection..ctor(PdfSharp.Pdf.PdfArray)' failed.

Can anyone help me with this?

Jul 10, 2010 at 3:51 PM
Actually this problem is pretty simple.
First of all try our new silverPDF 1.1. If this doesn't help do this. Download source code and go to "PdfSharp.Pdf.AcroForms". Then change all constructors in all classes of that folder to public. It should help you.
This problem happens because we use code from .NET libraries. Those libraries use Reflection. Reflection in .NET and Silverlight is different. Silverlight didn't allow to create classes that doesn't contain public constructor. So just change all classes constructors, (that threw and exception) to public and everything should be fine.