How to make a field not required?

I am trying to make a field not required using iText. I know that I can make a field required using something like below statement: formFields.setFieldProperty(field, "setfflags", PdfFormField.FF_

I am trying to make a field not required using iText. I know that I can make a field required using something like below statement:

formFields.setFieldProperty(field, "setfflags", PdfFormField.FF_REQUIRED, null);
Is there anything similar to make an existing field not required?

Posted on StackOverflow on Dec 1, 2014 by user2296988

By default, the "required field" flag is not set when creating a form field. As you indicate in your question, you can use the setFieldProperty() method to set this flag:

formFields.setFieldProperty(field, "setfflags", PdfFormField.FF_REQUIRED, null);

Based on your question, I assume that you have an existing PDF where you have fields for which this flag is already set. You can removed this flag (remove the bit from the bit set), by changing "setfflags" into "clrfflags":

formFields.setFieldProperty(field, "clrfflags", PdfFormField.FF_REQUIRED, null);

In this context clr stands for clear and fflags stands for field flags (not to be confused with clrflags which will clear flags in the widget annotation).


Share this article

Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial
Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now