11. How Do I Set Colors in CSS?

How do I set RGB colors? In CSS you can specify RGB colors in the following ways:

How do I set CMYK colors? Besides "rgb" PDFreactor also supports the non-standard function "cmyk". It takes the 4 CMYK component values as parameters in decimal or percent notation, e.g. "cmyk(0,0,1,0)" or "cmyk(0%,0%,100%,0%)" for perfect yellow.

Color key words can be converted automatically into CMYK by using the API method "setDefaultColorSpace":

pdfReactor.setDefaultColorSpace(PDFreactor.COLOR_SPACE_CMYK);

How do I set HSL colors? HSL is another representation of the RGB colorspace. The hue value is in the range of 0 to 360, the saturation and lightness values range between 0 and 1. It is possible to set HSL colors using the function "hsl". It takes the 3 HSL component values as parameters in decimal or percent notation, e.g. "hsl(240,0,0)" or "hsl(66%,0%,0%)" for blue.

How do I use color key words? Instead of using color functions or the hexadecimal notation a single human readable key word can be used. For more information which key words are supported by PDFreactor see the CSS Color Keywords table. The key words are internally converted into the user-set color space. By default, they are converted into RGB colors.