Dear iText developers:

 

I have been through several sources such as http://www.junlu.com/ and http://www.lowagie.com/iText/docs.html sites and found no solution to removing a background color in a checkbox. We are producing a PDF form with data on it. The blank form is read in as well as the FDF data, then the output to PDF combines the blank PDF form and the FDF data. However, in the blank PDF form, there are fields highlighted in yellow (which includes checkboxes). I was able to remove the yellow background of the regular text fields with the following code but not the yellow background on the checkboxes.

 

    HashMap fieldMap = fields.getFields();  // fields is of type AcroFields

    if ( fieldMap == null )

      return;

 

    Iterator fieldNamesIt = fieldMap.keySet().iterator();

    while ( fieldNamesIt.hasNext() )

    {

      String fieldName = (String) fieldNamesIt.next();

      if ( fieldName == null )

        continue;

 

      int fieldType = fields.getFieldType( fieldName );

 

      // Don't touch the bgcolor if pushbutton

      if ( AcroFields.FIELD_TYPE_PUSHBUTTON == fieldType )

        continue;

 

      // Remove the background color of all fields unless otherwise specified.

      Color bgcolor = null;

 

      // Special handling of SSN, PHONE fields' bgcolor - set to white if field value exists.

      if ( fieldName.toUpperCase().indexOf("SSN") >= 0 )

      {

        // No value is found in the (form) fields paramater.

        bgcolor = Color.white;

      }

 

      fields.setFieldProperty( fieldName, "bgcolor", bgcolor, null );

 

 

According to your documentation, fields.setFieldProperty(…) is the method that removes the background color. The background color of all of the text fields are successfully removed except for the checkboxes which still remain yellow. Please tell me how to remove the yellow background color of checkboxes. Thanks.

 

Rosie

 

Reply via email to