Currently, I am using the following code to set the color using Aspose.Color
return Color.FromRgb(3, 49, 63);
Which is a valid RGB value from a hex code #03313F
When i run this code, I get the following on the line.
Getting exception of:
System.ApplicationException: ‘Invalid input data: color element is out of range [0…1]’
Is aspose PDF limited to certain colors? Am i using this wrong?
@R_C_D_T
Thank you for contacting support.
We would like to request you to follow the approach suggested below, to set a color while avoiding specified exception.
//Set background color of text
textFragment.TextState.BackgroundColor = GetColor();
protected static Aspose.Pdf.Color GetColor()
{
Color color = Color.FromRgb(System.Drawing.Color.FromArgb(3, 49, 63));
//Color color = Color.FromRgb(System.Drawing.ColorTranslator.FromHtml("#03313F"));
return color;
}
This will enable you to set any color using its hex code or RGB values. We hope this will be helpful. Please feel free to contact us if you need any further assistance.