ImageGear v26.3 - Updated
Developer Guide / How to Work with ... / PDF / How to... / Work with PDF Forms / Modify Field Appearance
In This Topic
    Modify Field Appearance
    In This Topic

    ImageGear does not support modification of forms in PDF documents containing XFA. Please see XFA Support for more information.

    The Acrofroms API supports changing visual properties of fields, such as color, border, and text information. These are properties of the Field and WidgetAnnotation.

    Widget Border and Fill Properties

    The visual appearance of a widget annotation can be changed through the BorderStyleBorderColorBorderWidth and FillColor properties of a widget annotation.

    • FillColor and BorderColor can be set to a standard System.Drawing.Color object. Colors stored internally as grayscale or CMYK will be implicitly converted to RGB when accessing these properties.
    • BorderWidth can be set to any non-negative integer, or a preset property value provided by AnnotationBorderWidth.
    • BorderStyle is set to an entry in the AnnotationBorderStyle enumeration. The styles listed are equivalent to those provided by PDF.

    A BorderWidth of 0 will result in no border being drawn. A BorderStyle of SOLID will be returned as the default for fields with no border. A border of INSET is initially applied to RadioGroup fields created by ImageGear.

    Example border styles:

     BorderStyles

    C#

    void ModifyWidgetProperties(Field field)
    {
        foreach(WidgetAnnotation widget in field.Widgets)
        {
            // Set some fill and border colors.
            widget.FillColor = Color.Red;
            widget.BorderColor = Color.YellowGreen;
    
            // Set a thick border width (size 3).
            // Any integer can also be used.
            widget.BorderWidth = AnnotationBorderWidth.THICK;
    
            // Set a border style.
            widget.BorderStyle = AnnotationBorderStyle.DASHED;
        }
    }
    

    Field Text Properties and Fonts

    Most fields containing text have the ability to modify the FontNameFontSize, and TextColor of the displayed textual value.

    The applicable fields are TextFieldListBox,  ComboBox,  CheckBox,  SignatureField, and PushButton. Setting these properties for other fields will have no effect.

    • FontName refers to the PostScript name of a font currently on the system or embedded in the PDF, such as "Arial" or "Helvetica-Bold".
    • FontSize is a size in points specifying the size of the text.
    • TextColor can be set to any standard System.Drawing.Color object. Colors stored internally as grayscale or CMYK will be implicitly converted to RGB when accessing this property.

    Example FontName, FontSize, and TextColor applications to TextField:

    TextProperties

    C#

    void ModifyTextProperties(TextField field)
    {
        // Set some font settings.
        field.FontName = "Helvetica";
        field.FontSize = 22;
    
            // Color the text.
        field.TextColor = Color.BlanchedAlmond;
    }