javaAndBeyond
javaAndBeyond

Reputation: 540

Can I make a field not required in pdf using iText?

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

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

Is there anything similar to make an existing field not required?

Upvotes: 1

Views: 241

Answers (1)

Bruno Lowagie
Bruno Lowagie

Reputation: 77528

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).

Upvotes: 1

Related Questions