Hi
I think I have found a bug in the class
org.apache.pdfbox.pdmodel.interactive.form.PDRadioCollection
since the method getKids returns null in case no child is found the
following methods are throwing a NullPointerException: setValue , getValue
the fix that works and I am using on my machine is in red:
/**
* This setValue method iterates the collection of radiobuttons
* and checks or unchecks each radiobutton according to the
* given value.
* If the value is not represented by any of the radiobuttons,
* then none will be checked.
*
* {@inheritDoc}
*/
public void setValue(String value) throws IOException
{
getDictionary().setString( "V", value );
List kids = getKids();
for (int i = 0; *kids!=null &&* i < kids.size(); i++)
{
PDField field = (PDField)kids.get(i);
if ( field instanceof PDCheckbox )
{
PDCheckbox btn = (PDCheckbox)field;
if( btn.getOnValue().equals(value) )
{
btn.check();
}
else
{
btn.unCheck();
}
}
}
}
/**
* getValue gets the fields value to as a string.
*
* @return The string value of this field.
*
* @throws IOException If there is an error getting the value.
*/
public String getValue()throws IOException
{
String retval = null;
List kids = getKids();
for (int i = 0; *kids!=null && *i < kids.size(); i++)
{
PDField kid = (PDField)kids.get(i);
if ( kid instanceof PDCheckbox )
{
PDCheckbox btn = (PDCheckbox)kid;
if( btn.isChecked() )
{
retval = btn.getOnValue();
}
}
}
if( retval == null )
{
retval = getDictionary().getNameAsString( "V" );
}
return retval;
}
best regards
Gianandrea