---
Product: Aspose.PDF
Platform: java
Page Type: docs
Canonical URL: https://docs.aspose.org/pdf/java/developer-guide/colorspace
---

# Color Spaces

PDF color spaces and Color API in Aspose.PDF FOSS for Java.

## Color

The `Color` class represents color values used for annotation borders, backgrounds,
text, and shapes. Colors are created via factory methods:

```java
// 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:

```java
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.

## See Also

- [Aspose.PDF for Java — Enterprise Documentation](https://docs.aspose.com/pdf/java/)