Colour schemes define methods for representing colour. These methods depend on the viewing target. Colours on a computer screen are composed differently from colours on a printed paper. The previous sections of this documentation have all used the same colour scheme, RGB. The RGB colour scheme is the most natural for computer graphics as it maps directly onto the colours of computer displays. PDF Graphics .NET supports another major scheme for use with printed material, CMYK.
For most colours, a representation in one scheme can be converted easily to one in another scheme. However, this is not always true. Also, advanced effects such as colour gradients are not the same across colour schemes.
Therefore it is important to select the right colour scheme for your graphics. If the target PDF document is going to be displayed mostly on computer screens then the RGB scheme is best; for printed material, use CMYK.
RGB stands for red, green, blue. All colours in the RGB scheme are composed of these three primary colours, matching the colours that computer screens are made out of. To create a new RGB colour, use the RgbColour class:
The colour created in the example is a uniform yellow. It is composed of red and green, which results in yellow. The values for the red, green and blue components range from 0 (none) to 255 (full).
The PDF Graphics .NET library includes a number of standard RGB colours in the static RGB class, as well was matching pens and brushes. The above example can be rewritten as:
Printed material uses ink in three primary colours and black, and this scheme is referred to as CMYK after the cyan, magenta, yellow and black (key) ink. Creating a CMYK colour is done through the CMYK class. The example below fills a rectangle in a green colour:
Just like the RGB static class, the CMYK static class provides access to standard colours, pens and brushes so that the above code can be shortened to:
All graphics operations accept CMYK or RGB colours. Generally, no limits are imposed on the mixing of colour schemes so it's possible to fill a rectangle with an RGB colour and outline it using a CMYK pen.
The exception to this is colour gradients. Both colours in a gradient must be of the same colour scheme. PDF Graphics .NET will throw an exception otherwise.
Selecting the right colour scheme depends on the target display of the PDF document. A document that will primarily be viewed on a computer screen should use RGB colours to ensure that all colours are rendered faithfully. Documents that are meant to be printed should use the CMYK colour scheme.
Bitmap images are composed of colours, and these colours follow a colour scheme. Again, to ensure images are rendered faithfully their colour schemes should match that of the target viewer. Images created using simple computer tools will likely use the RGB scheme. More advanced imaging packages will allow the creation of CMYK images, or the conversion of RGB images to CMYK. Freehand or vector drawing packages usually allow CMYK image export.
Note: Again, there is no limitation to mixing colour schemes. A PDF page can contain CMYK images as well as RGB images. The primary reason for using a uniform colour scheme across a page or document is colour fidelity.