How to determine field type from a field in a PDF document using iTextSharp?

I'm experimenting with the iTextSharp library with C# and VisualStudio. I'm trying to obtain field names and field types (TextBox, RadioButton, ComboBox, CheckBox) from the AcroFields object.

Field names were easy to find but I'm struggling with field type. I've checked the iText javadoc because someone on here said the methods and functions should be similar in iTextSharp but have not found that to be the case.

Here's my code that get's the field names:

FormObject fo = new FormObject();
List<FormField> form_fields = new List<FormField>();

PdfReader reader = new PdfReader(file_name);
AcroFields reader_fields = reader.AcroFields;

foreach (KeyValuePair<String, iTextSharp.text.pdf.AcroFields.Item> entry in reader_fields.Fields)
{
    FormField ff = new FormField();
    ff.Field_name = entry.Key.ToString();
    form_fields.Add(ff);
}

Any ideas on how I can extract the field type from the AcroFields object? I know it has to be in there somewhere...

Answers


Was able to find field types this morning.

FormObject fo = new FormObject();
List<FormField> form_fields = new List<FormField>();

PdfReader reader = new PdfReader(file_name);
AcroFields reader_fields = reader.AcroFields;



foreach (KeyValuePair<String, iTextSharp.text.pdf.AcroFields.Item> entry in reader_fields.Fields)
{
    FormField ff = new FormField();
    ff.Field_name = entry.Key.ToString();
    int field_type = reader_fields.GetFieldType(entry.Key.ToString());
    form_fields.Add(ff);
}

Need Your Help

Python log-the-display problems

python logging scipy io-redirection

I'm trying to log the terminal display produced by a script which contains a Scipy optimization routine. I've tried three different ways, all with disappointing results.

Cannot catch wcf service exception in biztalk orchestration

exception-handling biztalk

I'm trying to put exception handling into my working orchestration and cannot get the exception caught. It keeps suspending the message instead of executing my exception block to handle it more

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.