Get field type in c#

New Here ,
Oct 17, 2021 Oct 17, 2021

Copy link to clipboard

Copied

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

TOPICS
Edit and convert PDFs , How to , PDF forms

Views

45

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Oct 18, 2021 Oct 18, 2021

Copy link to clipboard

Copied

Try the forum for Acrobat SDK.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 18, 2021 Oct 18, 2021

Copy link to clipboard

Copied

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

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 18, 2021 Oct 18, 2021

Copy link to clipboard

Copied

LATEST

Nevermind, I found that community and posted my question there. Thanks.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines