Hi,
I am trying to disable FormFields in the document. I tried doing it by using setEnabled(false)
This is not giving the expected results.
Please find attached document and source.
public class Test
{
public static void main(String args[])
{
try
{
Document doc = new Document();
String[] items = new String[] { "-- Select your favorite footwear --", "Sneakers", "Oxfords",
"Flip-flops", "Other", "I prefer to be barefoot" };
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertComboBox("combo1", items, 0);
builder.insertBreak(BreakType.LINE_BREAK);
builder.insertTextInput("text1", TextFormFieldType.REGULAR_TEXT, "", "This is in text input box",
0);
builder.insertBreak(BreakType.LINE_BREAK);
builder.writeln("Protected text");
builder
.writeln("Supplier shall maintain adequate and accurate records pertaining to any Goods purchased by");
builder.insertTextInput("text2", TextFormFieldType.REGULAR_TEXT, "", "More Text", 0);
FormFieldCollection formFieldCollection = doc.getRange().getFormFields();
for (Node formField : formFieldCollection)
{
System.out.println("formField.getNodeType() : " + formField.getNodeType());
if (formField.getNodeType() == NodeType.FORM_FIELD)
{
FormField ff = (FormField)formField;
System.out.println("ff " + ff.getName());
ff.setEnabled(false);
}
}
doc.save("C:/test.doc");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Thanks in advance.
Regards,
Tarul