public static PDField createField(PDAcroForm acroForm,
COSDictionary field) throws IOException {
PDField pdField = new PDUnknownField( acroForm, field );
if( isButton(pdField) )
{
int flags = pdField.getFieldFlags();
//BJL, I have found that the radio flag bit is not always set
//and that sometimes there is just a kids dictionary.
//so, if there is a kids dictionary then it must be a radio button
//group.
COSArray kids = (COSArray)field.getDictionaryObject( COSName.getPDFName( "Kids" ) );
if( kids != null || isRadio(flags) )
{
pdField = new PDRadioCollection( acroForm, field );
}
else if( isPushButton( flags ) )
{
pdField = new PDPushButton( acroForm, field );
}
else
{
pdField = new PDCheckbox( acroForm, field );
}
}
else if (isChoiceField(pdField))
{
pdField = new PDChoiceField( acroForm, field );
}
else if (isTextbox(pdField))
{
pdField = new PDTextbox( acroForm, field );
}
else if( isSignature( pdField ) )
{
pdField = new PDSignature( acroForm, field );
}
else
{
//do nothing and return an unknown field type.
}
return pdField;
}
This method creates a COSField subclass from the given field.
The field is a PDF Dictionary object that must represent a
field element. - othewise null is returned |