Color Spaces
Color
The Color class represents color values used for annotation borders, backgrounds,
text, and shapes. Colors are created via factory methods:
// RGB color with components in range [0.0, 1.0]
Color red = Color.fromRgb(1, 0, 0);
Color green = Color.fromRgb(0, 1, 0);
Color black = Color.BLACK;
Color white = Color.WHITE;Color.fromRgb(r, g, b) accepts three double values in [0.0, 1.0] for red, green,
and blue components. Named constants include Color.BLACK, Color.WHITE, and others.
Annotation Colors
Colors are used with AppearanceCharacteristics.setBorder(color) for annotation
borders and setBackground(color) for annotation fills:
WidgetAnnotation w = new WidgetAnnotation(page, new Rectangle(0, 0, 100, 50));
w.getCharacteristics().setBorder(Color.fromRgb(1, 0, 0));
w.getCharacteristics().setBackground(Color.fromRgb(0.9, 0.9, 1.0));PDF Color Spaces
PDF supports multiple color spaces including DeviceRGB, DeviceCMYK, DeviceGray,
and ICC-based spaces. The Color class maps to DeviceRGB for annotation use.