Class RadioCheckField
- Namespace
- iTextSharp.text.pdf
- Assembly
- iTextSharp.LGPLv2.Core.dll
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(); @author Paulo Soares (psoares@consiste.pt)
public class RadioCheckField : BaseField
- Inheritance
-
RadioCheckField
- Inherited Members
Constructors
RadioCheckField(PdfWriter, Rectangle, string, string)
Creates a new instance of RadioCheckField
public RadioCheckField(PdfWriter writer, Rectangle box, string fieldName, string onValue)
Parameters
writer
PdfWriterthe document PdfWriter
box
Rectanglethe field location and dimensions
fieldName
stringthe field name. It must not be null
onValue
stringthe value when the field is checked
Fields
TYPE_CHECK
A field with the symbol check
public const int TYPE_CHECK = 1
Field Value
TYPE_CIRCLE
A field with the symbol circle
public const int TYPE_CIRCLE = 2
Field Value
TYPE_CROSS
A field with the symbol cross
public const int TYPE_CROSS = 3
Field Value
TYPE_DIAMOND
A field with the symbol diamond
public const int TYPE_DIAMOND = 4
Field Value
TYPE_SQUARE
A field with the symbol square
public const int TYPE_SQUARE = 5
Field Value
TYPE_STAR
A field with the symbol star
public const int TYPE_STAR = 6
Field Value
Properties
CheckField
Gets the check field. @throws IOException on error @throws DocumentException on error
public PdfFormField CheckField { get; }
Property Value
- PdfFormField
the check field
CheckType
Sets the checked symbol. It can be TYPE_CHECK , TYPE_CIRCLE , TYPE_CROSS , TYPE_DIAMOND , TYPE_SQUARE and TYPE_STAR .
public int CheckType { get; set; }
Property Value
Checked
Sets the state of the field to checked or unchecked. and false for unchecked
public bool Checked { get; set; }
Property Value
OnValue
Sets the value when the field is checked.
public string OnValue { get; set; }
Property Value
RadioField
Gets the radio field. It's only composed of the widget keys and must be used with {@link #getRadioGroup(bool,bool)}. @throws IOException on error @throws DocumentException on error
public PdfFormField RadioField { get; }
Property Value
- PdfFormField
the radio field
Methods
GetAppearance(bool, bool)
Gets the field appearance. for a check field otherwise @throws IOException on error @throws DocumentException on error
public PdfAppearance GetAppearance(bool isRadio, bool on)
Parameters
Returns
- PdfAppearance
the appearance
GetAppearanceRadioCircle(bool)
Gets the special field appearance for the radio circle. otherwise
public PdfAppearance GetAppearanceRadioCircle(bool on)
Parameters
on
booltrue for the checked state, false
Returns
- PdfAppearance
the appearance
GetField(bool)
Gets a radio or check field. a check field @throws IOException on error @throws DocumentException on error
protected PdfFormField GetField(bool isRadio)
Parameters
isRadio
booltrue to get a radio field, false to get
Returns
- PdfFormField
the field
GetRadioGroup(bool, bool)
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 {@link PdfFormField#addKid(PdfFormField) AddKid()}. times; clicking the currently selected button has no effect. If false , clicking the selected button deselects it, leaving no button selected. use the same value for the on state will turn on and off in unison; that is if one is checked, they are all checked. If false , the buttons are mutually exclusive (the same behavior as HTML radio buttons)
public PdfFormField GetRadioGroup(bool noToggleToOff, bool radiosInUnison)
Parameters
noToggleToOff
boolif true , exactly one radio button must be selected at all
radiosInUnison
boolif true , a group of radio buttons within a radio button field that
Returns
- PdfFormField
the radio group