How to Create Spot Color in PDF in C#, VB.NET

Colors created without screens or dots are referred to in the industry as spot or solid colors. Spot colors are the preferred method of producing stationery inexpensively, and also the method used where color accuracy is deemed essential, for instance a company logo.

This article presents how to define a spot color based on RGB color spaces, create variations of a spot color with different tint value, and how to apply the spot color to text and graphic objects using Spire.PDF.

Step 1: Create a PdfDcoument object and add a page to it.

PdfDocument pdf = new PdfDocument();
PdfPageBase page = pdf.Pages.Add();

Step 2: Define the spot color "MySpotColor" from the built-in color.

PdfSeparationColorSpace cs = new PdfSeparationColorSpace("MySpotColor", Color.Purple);

Step 3: Set the spot color with a tint value of 1.

PdfSeparationColor color = new PdfSeparationColor(cs, 1f);

Step 4: Apply the spot color while drawing content on the page.

PdfSolidBrush brush = new PdfSolidBrush(color);
page.Canvas.DrawPie(brush, 10, 30, 60, 60, 360, 360);
page.Canvas.DrawString("1.0 tint!", new PdfFont(PdfFontFamily.Helvetica, 10f), brush, new PointF(20,100));

Step 5: Set the spot color with a tint value of 0.5 and apply it to some other content.

color = new PdfSeparationColor(cs, 0.5f);
brush = new PdfSolidBrush(color);
page.Canvas.DrawPie(brush, 80, 30, 60, 60, 360, 360);
page.Canvas.DrawString("Tint=0.5", new PdfFont(PdfFontFamily.Helvetica, 10f), brush, new PointF(92,100));

Step 6: Save the file.

pdf.SaveToFile("SpotColor.pdf");

Output:

How to Create Spot Color in PDF in C#, VB.NET

Full Code:

[C#]
PdfDocument pdf = new PdfDocument();
PdfPageBase page = pdf.Pages.Add();

PdfSeparationColorSpace cs = new PdfSeparationColorSpace("MySpotColor", Color.Purple);
PdfSeparationColor color = new PdfSeparationColor(cs, 1f);
PdfSolidBrush brush = new PdfSolidBrush(color);
page.Canvas.DrawPie(brush, 10, 30, 60, 60, 360, 360);
page.Canvas.DrawString("Tint=1.0", new PdfFont(PdfFontFamily.Helvetica, 10f), brush, new PointF(22,100));

color = new PdfSeparationColor(cs, 0.5f);
brush = new PdfSolidBrush(color);
page.Canvas.DrawPie(brush, 80, 30, 60, 60, 360, 360);
page.Canvas.DrawString("Tint=0.5", new PdfFont(PdfFontFamily.Helvetica, 10f), brush, new PointF(92,100));

color = new PdfSeparationColor(cs, 0.25f);
brush = new PdfSolidBrush(color);
page.Canvas.DrawPie(brush, 150, 30, 60, 60, 360, 360);
page.Canvas.DrawString("Tint=0.25", new PdfFont(PdfFontFamily.Helvetica, 10f), brush, new PointF(162, 100));
pdf.SaveToFile("SpotColor.pdf");
[VB.NET]
Dim pdf As PdfDocument = New PdfDocument()
Dim page As PdfPageBase = pdf.Pages.Add()

Dim cs As PdfSeparationColorSpace = New PdfSeparationColorSpace("MySpotColor", Color.Purple)
Dim color As PdfSeparationColor = New PdfSeparationColor(cs,1f)
Dim brush As PdfSolidBrush = New PdfSolidBrush(color)
page.Canvas.DrawPie(brush, 10, 30, 60, 60, 360, 360)
page.Canvas.DrawString("Tint=1.0", New PdfFont(PdfFontFamily.Helvetica, 10f), brush, New PointF(22,100))
 
color = New PdfSeparationColor(cs, 0.5f)
brush = New PdfSolidBrush(color)
page.Canvas.DrawPie(brush, 80, 30, 60, 60, 360, 360)
page.Canvas.DrawString("Tint=0.5", New PdfFont(PdfFontFamily.Helvetica, 10f), brush, New PointF(92,100))
 
color = New PdfSeparationColor(cs, 0.25f)
brush = New PdfSolidBrush(color)
page.Canvas.DrawPie(brush, 150, 30, 60, 60, 360, 360)
page.Canvas.DrawString("Tint=0.25", New PdfFont(PdfFontFamily.Helvetica, 10f), brush, New PointF(162, 100))
pdf.SaveToFile("SpotColor.pdf")