# Customizing Text and Border Colors to Highlight a TextBoxField with RadPdfProcessing

## Environment

| Version     | Product          | Author                                                                          |
| ----------- | ---------------- | ------------------------------------------------------------------------------- |
| 2024.4.1106 | RadPdfProcessing | [Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova) |

## Description

When you create PDF documents that contain [form fields](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/formfields), you may need to update the text and border colors of a [TextBoxField](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/textboxfield) and highlight specific fields. This article shows how to customize the appearance of `TextBoxField` elements, including changing their text and border colors.

![Highlight TextBox Field](https://www.telerik.com/document-processing-libraries/documentation/assets/0cee58b45ba2597fc9df771d04618c40/highlight-textbox-field.gif)

## Solution

To change the text and border colors of a `TextBoxField` in a PDF document, use the `TextProperties` and `AppearanceCharacteristics` properties provided by the [VariableContentWidget](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/annotations/widgets) class. The following example shows how to customize these aspects.

1. Create a new [RadFixedDocument](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/radfixeddocument) and add a page to it.
2. Create a `TextBoxField` and configure its properties as needed.
3. Add a widget to the `TextBoxField` and set the text and border colors through the `TextProperties` and [AppearanceCharacteristics](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/dynamic-appearance-properties) properties.
4. Recalculate the content of the widget and add the `TextBoxField` to the document.
5. Save the document to a file.

```csharp
RadFixedDocument fixedDocument = new RadFixedDocument();
fixedDocument.Pages.AddPage();

TextBoxField textField = new TextBoxField("SampleTextBox")
{
    MaxLengthOfInputCharacters = 500,
    IsMultiline = true,
    IsPassword = false,
    IsFileSelect = false,
    ShouldSpellCheck = true,
    AllowScroll = true,
    Value = "Sample content",
};

VariableContentWidget widget = textField.Widgets.AddWidget();
VariableTextProperties textProperties = new VariableTextProperties();
textProperties.Fill = new RgbColor(255, 0, 0); // Set text color to red
textProperties.FontSize = 24; 
widget.TextProperties = textProperties;

widget.AppearanceCharacteristics.BorderColor = new RgbColor(0, 0, 0); // Set border color to black
widget.AppearanceCharacteristics.Background = new RgbColor(255, 255, 0); // Optional: Set background color to yellow
widget.Rect = new Rect(10, 10, 250, 50);
widget.RecalculateContent();

fixedDocument.AcroForm.FormFields.Add(textField);
fixedDocument.Pages[0].Annotations.Add(widget);

string fileName = "CustomizedTextBoxField.pdf";
File.WriteAllBytes(fileName, new PdfFormatProvider().Export(fixedDocument, TimeSpan.FromSeconds(10)));

Console.WriteLine("Document with customized TextBoxField created.");
```

This approach applies not only to creating new documents but also to importing documents that already contain form fields.

## See Also

* [TextBoxField Documentation](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/textboxfield)
* [Text and Graphic Properties](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/text-and-graphic-properties)
* [Create Interactive Forms SDK Example](https://github.com/telerik/document-processing-sdk/tree/master/PdfProcessing/CreateInteractiveForms)
* [Modify Form Values SDK Example](https://github.com/telerik/document-processing-sdk/tree/master/PdfProcessing/ModifyForms)
