Save This Page
Home » iText-src-2.1.3 » com.lowagie » text » pdf » [javadoc | source]
com.lowagie.text.pdf
public class: RadioCheckField [javadoc | source]
java.lang.Object
   com.lowagie.text.pdf.BaseField
      com.lowagie.text.pdf.RadioCheckField
Creates a radio or a check field.

Example usage:

Document document = new Document(PageSize.A4, 50, 50, 50, 50);
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("output.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
RadioCheckField bt = new RadioCheckField(writer, new Rectangle(100, 100, 200, 200), "radio", "v1");
bt.setCheckType(RadioCheckField.TYPE_CIRCLE);
bt.setBackgroundColor(Color.cyan);
bt.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
bt.setBorderColor(Color.red);
bt.setTextColor(Color.yellow);
bt.setBorderWidth(BaseField.BORDER_WIDTH_THICK);
bt.setChecked(false);
PdfFormField f1 = bt.getRadioField();
bt.setOnValue("v2");
bt.setChecked(true);
bt.setBox(new Rectangle(100, 300, 200, 400));
PdfFormField f2 = bt.getRadioField();
bt.setChecked(false);
PdfFormField top = bt.getRadioGroup(true, false);
bt.setOnValue("v3");
bt.setBox(new Rectangle(100, 500, 200, 600));
PdfFormField f3 = bt.getRadioField();
top.addKid(f1);
top.addKid(f2);
top.addKid(f3);
writer.addAnnotation(top);
bt = new RadioCheckField(writer, new Rectangle(300, 300, 400, 400), "check1", "Yes");
bt.setCheckType(RadioCheckField.TYPE_CHECK);
bt.setBorderWidth(BaseField.BORDER_WIDTH_THIN);
bt.setBorderColor(Color.black);
bt.setBackgroundColor(Color.white);
PdfFormField ck = bt.getCheckField();
writer.addAnnotation(ck);
document.close();
Field Summary
public static final  int TYPE_CHECK    A field with the symbol check 
public static final  int TYPE_CIRCLE    A field with the symbol circle 
public static final  int TYPE_CROSS    A field with the symbol cross 
public static final  int TYPE_DIAMOND    A field with the symbol diamond 
public static final  int TYPE_SQUARE    A field with the symbol square 
public static final  int TYPE_STAR    A field with the symbol star 
Fields inherited from com.lowagie.text.pdf.BaseField:
BORDER_WIDTH_THIN,  BORDER_WIDTH_MEDIUM,  BORDER_WIDTH_THICK,  VISIBLE,  HIDDEN,  VISIBLE_BUT_DOES_NOT_PRINT,  HIDDEN_BUT_PRINTABLE,  READ_ONLY,  REQUIRED,  MULTILINE,  DO_NOT_SCROLL,  PASSWORD,  FILE_SELECTION,  DO_NOT_SPELL_CHECK,  EDIT,  COMB,  borderWidth,  borderStyle,  borderColor,  backgroundColor,  textColor,  font,  fontSize,  alignment,  writer,  text,  box,  rotation,  visibility,  fieldName,  options,  maxCharacterLength
Constructor:
 public RadioCheckField(PdfWriter writer,
    Rectangle box,
    String fieldName,
    String onValue) 
    Creates a new instance of RadioCheckField
    Parameters:
    writer - the document PdfWriter
    box - the field location and dimensions
    fieldName - the field name. It must not be null
    onValue - the value when the field is checked
Method from com.lowagie.text.pdf.RadioCheckField Summary:
getAppearance,   getAppearanceRadioCircle,   getCheckField,   getCheckType,   getField,   getOnValue,   getRadioField,   getRadioGroup,   isChecked,   setCheckType,   setChecked,   setOnValue
Methods from com.lowagie.text.pdf.BaseField:
breakLines,   getAlignment,   getBackgroundColor,   getBorderAppearance,   getBorderColor,   getBorderStyle,   getBorderWidth,   getBox,   getFieldName,   getFont,   getFontSize,   getHardBreaks,   getMaxCharacterLength,   getOptions,   getRealFont,   getRotation,   getText,   getTextColor,   getVisibility,   getWriter,   moveFields,   setAlignment,   setBackgroundColor,   setBorderColor,   setBorderStyle,   setBorderWidth,   setBox,   setFieldName,   setFont,   setFontSize,   setMaxCharacterLength,   setOptions,   setRotation,   setRotationFromPage,   setText,   setTextColor,   setVisibility,   setWriter,   trimRight
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.lowagie.text.pdf.RadioCheckField Detail:
 public PdfAppearance getAppearance(boolean isRadio,
    boolean on) throws IOException, DocumentException 
    Gets the field appearance.
 public PdfAppearance getAppearanceRadioCircle(boolean on) 
    Gets the special field appearance for the radio circle.
 public PdfFormField getCheckField() throws IOException, DocumentException 
    Gets the check field.
 public int getCheckType() 
    Getter for property checkType.
 protected PdfFormField getField(boolean isRadio) throws IOException, DocumentException 
    Gets a radio or check field.
 public String getOnValue() 
    Getter for property onValue.
 public PdfFormField getRadioField() throws IOException, DocumentException 
 public PdfFormField getRadioGroup(boolean noToggleToOff,
    boolean radiosInUnison) 
    Gets a radio group. It's composed of the field specific keys, without the widget ones. This field is to be used as a field aggregator with addKid() .
 public boolean isChecked() 
    Getter for property checked.
 public  void setCheckType(int checkType) 
    Sets the checked symbol. It can be TYPE_CHECK, TYPE_CIRCLE, TYPE_CROSS, TYPE_DIAMOND, TYPE_SQUARE and TYPE_STAR.
 public  void setChecked(boolean checked) 
    Sets the state of the field to checked or unchecked.
 public  void setOnValue(String onValue) 
    Sets the value when the field is checked.