๐ญ 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 });
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
| Space | Constructor | Best For |
|---|---|---|
| RGB | new PdfColor(r, g, b) | Screen display, web PDFs |
| CMYK | PdfColor.FromCmyk(c, m, y, k) | Professional print production |
| Grayscale | PdfColor.FromGray(gray) | B&W documents, reducing file size |