protected PdfFormField getField ( boolean isRadio ) throws IOException , DocumentException { PdfFormField field = null ; if ( isRadio ) field = PdfFormField . createEmpty ( writer ) ; else field = PdfFormField . createCheckBox ( writer ) ; field . setWidget ( box , PdfAnnotation . HIGHLIGHT_INVERT ) ; if ( ! isRadio ) { field . setFieldName ( fieldName ) ; if ( ( options & READ_ONLY ) != 0 ) field . setFieldFlags ( PdfFormField . FF_READ_ONLY ) ; if ( ( options & REQUIRED ) != 0 ) field . setFieldFlags ( PdfFormField . FF_REQUIRED ) ; field . setValueAsName ( checked ? onValue : "Off" ) ; } if ( text != null ) field . setMKNormalCaption ( text ) ; if ( rotation != 0 ) field . setMKRotation ( rotation ) ; field . setBorderStyle ( new PdfBorderDictionary ( borderWidth , borderStyle , new PdfDashPattern ( 3 ) ) ) ; PdfAppearance tpon = getAppearance ( isRadio , true ) ; PdfAppearance tpoff = getAppearance ( isRadio , false ) ; field . setAppearance ( PdfAnnotation . APPEARANCE_NORMAL , onValue , tpon ) ; field . setAppearance ( PdfAnnotation . APPEARANCE_NORMAL , "Off" , tpoff ) ; field . setAppearanceState ( checked ? onValue : "Off" ) ; PdfAppearance da = ( PdfAppearance ) tpon . getDuplicate ( ) ; da . setFontAndSize ( getRealFont ( ) , fontSize ) ; if ( textColor == null ) da . setGrayFill ( 0 ) ; else da . setColorFill ( textColor ) ; field . setDefaultAppearanceString ( da ) ; if ( borderColor != null ) field . setMKBorderColor ( borderColor ) ; if ( backgroundColor != null ) field . setMKBackgroundColor ( backgroundColor ) ; switch ( visibility ) { case HIDDEN : field . setFlags ( PdfAnnotation . FLAGS_PRINT | PdfAnnotation . FLAGS_HIDDEN ) ; break ; case VISIBLE_BUT_DOES_NOT_PRINT : break ; case HIDDEN_BUT_PRINTABLE : field . setFlags ( PdfAnnotation . FLAGS_PRINT | PdfAnnotation . FLAGS_NOVIEW ) ; break ; default : field . setFlags ( PdfAnnotation . FLAGS_PRINT ) ; break ; } return field ; }
Gets a radio or check field .