How can I disable a button Field in a form on Android?

I’m using PDFTron on Android.

I have a form that contains a button field (see attached image). I’m using PDFViewCtrl to view the PDF doc. When the user clicks that button, the app freezes and locks up. I need to be able to disable the button so that the user clicks have no effect.

I can iterate through the Fields in the doc like so:

for(FieldIterator itr = doc.getFieldIterator(); itr.hasNext():wink: {

Field current=(Field)(itr.next());

if (current.getType() == Field.e_button && current.getName().toUpperCase().contains(“SUBMIT”)) {

// need magic incantation to disable current HERE

}

System.out.println("Field name: " + current.getName());

System.out.println("Field partial name: " + current.getPartialName());

System.out.println("Field type: " + current.getType() + “\n”);

}

What I need is a way to make the doc ignore clicks on that button or remove the button programmatically or hide it…something.

Any ideas?

Thanks,

Ferrol Blackmon

form_sample.png

Hi, I would not recommend modifying particular fields in a PDF file.

I would post the PDF here, or send to support, and we can investigate why it is locking up.

Without seeing the PDF, I suspect deleting the AA entry in the field would fix the problem.

`
field.getSDFObj().erase(“AA”);

`

Hi Ryan,

Thanks for the reply. I gave that fix a try and it didn’t seem to do anything. I don’t understand what the “AA” refers to here. At any rate, I’m including a copy of the offending PDF form.

Ferrol

61392ed7-8632-488a-a65f-19f209aaae80.pdf (516 KB)

Hi, looking at the PDF I don’t see any actions at all connected with that button, so nothing is happening

Are you able to reproduce the hang in one of the SDK samples? Otherwise, there must be some custom logic in your project.

Hi Ryan,

I loaded the form I sent previously above into the PDFTron sample PDFViewCtrl Demo and it locked up in there also.

Thanks,

Ferrol

Hi Ryan,

Yes, I am able to reproduce the hang with the above PDF file in the PDFViewCtrlDemo.

Thanks,

Ferrol

Hi Ferrol,

You got a hang by clicking the Submit button on page 1 of the document you attached in the earlier post in our Android PDFViewCtrl sample, and that sample was unmodified? I am unable to reproduce in that case, and it really seems implausible since there just is no action that would be triggered for that annotation. If clicking that causes a hang on that button, it would do it on many other ones.

I tried using the latest Android PDFNet SDK, so if you are on an older version, then please update to the latest (6.5).

If you are modifying the sample, then please send me the code. thanks

Hi Ryan,

Thanks so much for your help. Upgrading to the latest library fixed the issue.

Ferrol