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:
Full Code:
using Spire.Pdf; using Spire.Pdf.ColorSpace; using Spire.Pdf.Graphics; using System.Drawing; namespace SpotColor { class Program { static void Main(string[] args) { 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"); } } }
Imports Spire.Pdf Imports Spire.Pdf.ColorSpace Imports Spire.Pdf.Graphics Imports System.Drawing Namespace SpotColor Class Program Private Shared Sub Main(args As String()) Dim pdf As New PdfDocument() Dim page As PdfPageBase = pdf.Pages.Add() Dim cs As New PdfSeparationColorSpace("MySpotColor", Color.Purple) Dim color__1 As New PdfSeparationColor(cs, 1F) Dim brush As New PdfSolidBrush(color__1) 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__1 = New PdfSeparationColor(cs, 0.5F) brush = New PdfSolidBrush(color__1) 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__1 = New PdfSeparationColor(cs, 0.25F) brush = New PdfSolidBrush(color__1) 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") End Sub End Class End Namespace