Aspose PDF Form Field Background Color

I am using a PDF with form fields. When the user click into the field I would like to change the background color to yellow indicating the filed is being updated. When load the PDF, I loop through all the form fields populating them with data. I tried using textBoxField.Color to change the background color when clicking into a form field, but that does not work. Is there a way to set the background color of a form field that is being updated?

Below is my code:

Do While myDr.dr.Read
textBoxField = TryCast(pdfDocument.Form(myDr.dr(“FR_QUESTIONNO”)), TextBoxField)
textBoxField.Value = myDr.dr(“FR_Student_Response_Txt”)
textBoxField.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green)
Loop

Hi Jim,

Thanks for contacting support.

In order to change the color of a form field i.e TextBox, you may set the Background property of the field to any Color. Please check the following code snippet to change the background color of the textbox in a PDF document.

Document doc = new Document(dataDir + "input.pdf");

foreach (Field field in doc.Form.Fields)
{
    if (field is TextBoxField)
    {
        field.Characteristics.Background = Color.Green;
    }
}

doc.Save(dataDir + "output.pdf");

Please try using above code snippet to set the background color of the field after updating its value. If you need any further assistance please feel free to contact us.

Best Regards,