Skip to main content
Participant
October 17, 2021
Question

Get field type in c#

  • October 17, 2021
  • 1 reply
  • 684 views

Hi,

I know there's 3rd party libraries that can integrate reading and writing to pdf's in c# but I'm trying not to use them at the moment.  I've figured out how to open and read the field names from the pdf, as well as getting a specific field by calling InvokeMember and and using GetJSObject to getNthFieldName.  What I'm trying to figure out now is by knowing the field name, is it possible to get the type of field i.e. text, radio button, checkbox, etc.  Also, if it's a radio button, the values that can be selected and so on.  Anyone able to help me figure this out? 

 

Here's a snippet of what I've tried:

Acrobat.AcroApp acroApp = new();
Acrobat.AcroPDDoc acroPDDoc = new();
acroPDDoc.Open($@"{filesHolder.PdfFile}");
object jso = acroPDDoc.GetJSObject();

object[] args = new object[] { fieldPair.Value }; // the value is the index number on the pdf sheet to get the nth field name.  this works for me.
object nthFieldName = jso.GetType().InvokeMember("getNthFieldName", BindingFlags.InvokeMethod, null, jso, args);
pdfField = nthFieldName.ToString();
args = new object[] { pdfField };

// not sure if this right, doesn't seem to be working for me, think this might be used for getting the value of the field and not the field type.
object nthField = jso.GetType().InvokeMember("GetField", BindingFlags.InvokeMethod, null, jso, args); 

 

I'm not sure which method to invoke to get the field type or if I'm completely on the wrong path for figuring it out.

 

Thanks,

Alan

This topic has been closed for replies.

1 reply

Bernd Alheit
Community Expert
Community Expert
October 18, 2021

Try the forum for Acrobat SDK.

Participant
October 18, 2021

Sounds good, I'll try there. Is there a way I can change the topic to that forum or I will need to repost my question there?

 

Thanks,

Alan