Iterator<COSObjectable> widgetIter = widgets.iterator();
while( widgetIter.hasNext() )
{
COSObjectable next = widgetIter.next();
PDField field = null;
PDAnnotationWidget widget = null;
if( next instanceof PDField )
{
field = (PDField)next;
widget = field.getWidget();
}
else
{
widget = (PDAnnotationWidget)next;
}
PDFormFieldAdditionalActions actions = null;
if( field != null )
{
actions = field.getActions();
}
if( actions != null &&
actions.getF() != null &&
widget.getDictionary().getDictionaryObject( COSName.AP ) ==null)
{
//do nothing because the field will be formatted by acrobat
//when it is opened. See FreedomExpressions.pdf for an example of this.
}
else
{
PDAppearanceDictionary appearance = widget.getAppearance();
if( appearance == null )
{
appearance = new PDAppearanceDictionary();
widget.setAppearance( appearance );
}
Map normalAppearance = appearance.getNormalAppearance();
PDAppearanceStream appearanceStream = (PDAppearanceStream)normalAppearance.get( "default" );
if( appearanceStream == null )
{
COSStream cosStream = new COSStream( acroForm.getDocument().getDocument().getScratchFile() );
appearanceStream = new PDAppearanceStream( cosStream );
appearanceStream.setBoundingBox( widget.getRectangle().createRetranslatedRectangle() );
appearance.setNormalAppearance( appearanceStream );
}
List tokens = getStreamTokens( appearanceStream );
List daTokens = getStreamTokens( getDefaultAppearance() );