๐ŸŽญ Colour Spaces

RGB, CMYK, and grayscale colour spaces for screen and print workflows.

C# โ€” Colour Spaces
// RGB colours (0.0 โ€“ 1.0 per channel)
// Best for screen display and web PDFs
var red   = new PdfColor(1.0, 0.0, 0.0);
var green = new PdfColor(0.0, 0.8, 0.2);
var blue  = new PdfColor(0.1, 0.3, 0.9);

page.FillRectangle(72, 650, 60, 40,
    new PdfDrawOptions { FillColor = red });
page.FillRectangle(142, 650, 60, 40,
    new PdfDrawOptions { FillColor = green });
page.FillRectangle(212, 650, 60, 40,
    new PdfDrawOptions { FillColor = blue });

// CMYK colours (0.0 โ€“ 1.0 per channel)
// Best for professional print production
var cmykRed = PdfColor.FromCmyk(
    0, 1.0, 1.0, 0);     // Process red
var cmykBlue = PdfColor.FromCmyk(
    1.0, 0.7, 0, 0);     // Process blue
var cmykBlack = PdfColor.FromCmyk(
    0, 0, 0, 1.0);       // Rich black

page.FillRectangle(72, 550, 60, 40,
    new PdfDrawOptions { FillColor = cmykRed });
page.FillRectangle(142, 550, 60, 40,
    new PdfDrawOptions { FillColor = cmykBlue });
page.FillRectangle(212, 550, 60, 40,
    new PdfDrawOptions { FillColor = cmykBlack });

// Grayscale (0.0 black โ€“ 1.0 white)
var dark = PdfColor.FromGray(0.2);
var mid  = PdfColor.FromGray(0.5);
var lite = PdfColor.FromGray(0.8);

page.FillRectangle(72, 450, 60, 40,
    new PdfDrawOptions { FillColor = dark });
page.FillRectangle(142, 450, 60, 40,
    new PdfDrawOptions { FillColor = mid });
page.FillRectangle(212, 450, 60, 40,
    new PdfDrawOptions { FillColor = lite });
Screenshot of the Colour Spaces PDF showing three rows of colour swatches: the top row with three RGB squares in red, green, and blue; the middle row with three CMYK squares in process red, blue, and black; and the bottom row with three grayscale squares from dark to light โ€” each row labeled with its colour space name

You should see a bold "Colour Spaces" heading and three labelled rows of swatches: an RGB row (red, green, blue squares), a CMYK row (process red, blue, and black squares), and a Grayscale row (dark grey, mid grey, light grey squares). Each row is labelled with its colour space name.
File: 20_colour_spaces.pdf

Colour Space Guide

SpaceConstructorBest For
RGBnew PdfColor(r, g, b)Screen display, web PDFs
CMYKPdfColor.FromCmyk(c, m, y, k)Professional print production
GrayscalePdfColor.FromGray(gray)B&W documents, reducing file size

โ™ฟ Accessibility Tip

Colour alone should never be the only way to convey information (WCAG 1.4.1). Ensure sufficient contrast between text and background โ€” use ObviousPDF's built-in contrast checking utility to verify WCAG AA (4.5:1) or AAA (7:1) ratios.