๐ŸŒˆ Gradients & Patterns

Axial and radial gradients, tiling patterns for backgrounds and decorative fills.

C# โ€” Gradients & Patterns
// Linear (axial) gradient
var grad = new PdfShadingPattern(
    PdfShadingType.Axial,
    x0: 72, y0: 650, x1: 300, y1: 650,
    color0: new PdfColor(0.1, 0.3, 0.8),
    color1: new PdfColor(0.4, 0.9, 0.6));
page.FillWithShading(grad, 72, 620, 228, 60);

// Radial gradient
var radial = new PdfShadingPattern(
    PdfShadingType.Radial,
    x0: 440, y0: 650, x1: 440, y1: 650,
    color0: new PdfColor(1, 0.9, 0.2),
    color1: new PdfColor(0.9, 0.2, 0.1));
radial.R0 = 0;   // Centre
radial.R1 = 70;  // Outer radius
page.FillWithShading(radial, 370, 580, 140, 140);

// Tiling pattern (stripes)
var stripe = new PdfTilingPattern(10, 10);
stripe.Content.SetNonStrokingColorRgb(
    0.85, 0.85, 0.95);
stripe.Content.AppendRectangle(0, 0, 10, 10);
stripe.Content.Fill();
stripe.Content.SetNonStrokingColorRgb(
    0.7, 0.7, 0.85);
stripe.Content.AppendRectangle(0, 0, 5, 10);
stripe.Content.Fill();
page.FillWithPattern(stripe, 72, 480, 228, 80);
Screenshot of the Gradients and Patterns PDF showing a blue-to-green linear gradient rectangle, a yellow-to-red radial gradient circle, a vertical stripe tiling pattern in purple, and a dot tiling pattern in blue โ€” all as decorative artifact elements

You should see a bold heading followed by four visual samples arranged in two rows: a wide rectangle shading from deep blue to bright green (linear gradient) beside a circle fading from warm yellow at the centre to red at the edge (radial gradient); below that, a purple-toned vertical stripe tile pattern beside a white field dotted with blue squares (dot tile). Each sample has a small descriptive label beneath it.
File: 13_gradients_patterns.pdf

โ™ฟ Accessibility Tip

Gradients and patterns are decorative โ€” always wrap them in BeginArtifact(PdfArtifactType.Layout) so screen readers skip them.