Free Support Forum - aspose.com

How to set RadioButtonOptionField Border and Fill colors


#1

I am using Aspose.PDF 19.1 for .NET. I am trying to create a RadioButtonOptionField with a solid, visible border. I can successfully set the TextColor for the field, but no joy for the Border nor Fill colors. In the following code, the Color for neither the RadioButtonField nor for the RadioButtonOptionField has any effect on the output. I am using red, yellow, and green colors so the effects would stand out for testing purposes. What do I need to do differently?

private void AddAsposeRB(Document docFileToConvert)
    {
        RadioButtonField rf = new RadioButtonField(docFileToConvert.Pages[1]);
        rf.PartialName = "GroupedRadio";

        Rectangle rect = new Rectangle(50, 75, 100, 125);

        RadioButtonOptionField option = new RadioButtonOptionField(docFileToConvert.Pages[1], rect);

        option.OptionName = "Yes";
        option.Width = 50;
        option.Height = 50;
        
        option.Caption = new TextFragment("Yes");
        rf.MappingName = "1";
        rf.Add(option);

        option.Color = Color.FromRgb(System.Drawing.Color.Yellow);

        option.Border = new Border(option);
        option.Border.Style = Aspose.Pdf.Annotations.BorderStyle.Solid;
        option.Border.Width = 2;
        option.DefaultAppearance.TextColor = (System.Drawing.Color.Red);

        rf.Border = new Border(rf);
        rf.Border.Style = Aspose.Pdf.Annotations.BorderStyle.Solid;
        rf.Border.Width = 2;

        rf.Color = Color.FromRgb(System.Drawing.Color.Green);
        rf.Style = BoxStyle.Check;
    }

#2

Just found another post that illustrated using

option.Characteristics.Border = System.Drawing.Color.Black;

and that worked.


#3

@hopfmn13

Thanks for acknowledgement.

It is good to know that your requirements have been accomplished. Please keep using our API and in case of any further assistance, please feel free to let us know.