Example #1
0
        public PdfFormField AddRadioButton(PdfFormField radiogroup, string value, float llx, float lly, float urx, float ury)
        {
            PdfFormField radio = PdfFormField.CreateEmpty(writer);

            radio.SetWidget(new Rectangle(llx, lly, urx, ury), PdfAnnotation.HIGHLIGHT_TOGGLE);
            string name = ((PdfName)radiogroup.Get(PdfName.V)).ToString().Substring(1);

            if (name.Equals(value))
            {
                radio.AppearanceState = value;
            }
            else
            {
                radio.AppearanceState = "Off";
            }
            DrawRadioAppearences(radio, value, llx, lly, urx, ury);
            radiogroup.AddKid(radio);
            return(radio);
        }
Example #2
0
 public PdfFormField AddRadioButton(PdfFormField radiogroup, string value, float llx, float lly, float urx, float ury)
 {
     PdfFormField radio = PdfFormField.CreateEmpty(writer);
     radio.SetWidget(new Rectangle(llx, lly, urx, ury), PdfAnnotation.HIGHLIGHT_TOGGLE);
     string name = ((PdfName)radiogroup.Get(PdfName.V)).ToString().Substring(1);
     if (name.Equals(value)) {
     radio.AppearanceState = value;
     }
     else {
     radio.AppearanceState = "Off";
     }
     DrawRadioAppearences(radio, value, llx, lly, urx, ury);
     radiogroup.AddKid(radio);
     return radio;
 }
Example #3
0
 /**
 * Replaces the designated field with a new pushbutton. The pushbutton can be created with
 * {@link #getNewPushbuttonFromField(String,int)} from the same document or it can be a
 * generic PdfFormField of the type pushbutton.
 * @param field the field name
 * @param button the <CODE>PdfFormField</CODE> representing the pushbutton
 * @param order the field order in fields with same name
 * @return <CODE>true</CODE> if the field was replaced, <CODE>false</CODE> if the field
 * was not a pushbutton
 */
 public bool ReplacePushbuttonField(String field, PdfFormField button, int order)
 {
     if (GetFieldType(field) != FIELD_TYPE_PUSHBUTTON)
         return false;
     Item item = GetFieldItem(field);
     if (order >= item.Size)
         return false;
     PdfDictionary merged = item.GetMerged(order);
     PdfDictionary values = item.GetValue(order);
     PdfDictionary widgets = item.GetWidget(order);
     for (int k = 0; k < buttonRemove.Length; ++k) {
         merged.Remove(buttonRemove[k]);
         values.Remove(buttonRemove[k]);
         widgets.Remove(buttonRemove[k]);
     }
     foreach (PdfName key in button.Keys) {
         if (key.Equals(PdfName.T) || key.Equals(PdfName.RECT))
             continue;
         if (key.Equals(PdfName.FF))
             values.Put(key, button.Get(key));
         else
             widgets.Put(key, button.Get(key));
         merged.Put(key, button.Get(key));
     }
     return true;
 }