New to Telerik Document Processing? Start a free 30-day trial
Customizing Text and Border Colors to Highlight a TextBoxField with RadPdfProcessing
Updated on Jun 9, 2026
Environment
| Version | Product | Author |
|---|---|---|
| 2024.4.1106 | RadPdfProcessing | Desislava Yordanova |
Description
When you create PDF documents that contain form fields, you may need to update the text and border colors of a TextBoxField and highlight specific fields. This article shows how to customize the appearance of TextBoxField elements, including changing their text and border colors.

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 class. The following example shows how to customize these aspects.
- Create a new RadFixedDocument and add a page to it.
- Create a
TextBoxFieldand configure its properties as needed. - Add a widget to the
TextBoxFieldand set the text and border colors through theTextPropertiesand AppearanceCharacteristics properties. - Recalculate the content of the widget and add the
TextBoxFieldto the document. - 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.