Doc ColorSpace Property. The current ColorSpace ID. ABCpdf .NET PDF Library.

ABCpdf .net

 
   

 

Type Default Read Only Description
[C#] int

[Visual Basic]
Integer
  0 No The current ColorSpace ID.

 

   

Notes
 

The current color space.

The ColorSpace is used when the Color is of a matching type. If the color type does not match then the default - device - color space is used.

For example you add a CMYK color space and assign it to the ColorSpace property. All CMYK Colors you use will be defined in terms of this color space. However RGB and Grayscale colors will continue to be defined in terms of the default - device - color spaces.

To get a ColorSpace ID you need to add your color space to the current document using the AddColorSpaceFile or AddColorSpaceSpot method.

 

   

Example
 

The following code shows how to colorize an image. It adds a base image to the current page and converts it to grayscale. Then it creates a new spot color space and assigns the new color space to the image.

[C#]
Doc theDoc = new Doc();
theDoc.Rect.Inset(20, 20);

XImage theImg = new XImage();
theImg.SetFile(Server.MapPath("../mypics/mypic.jpg"));
int theID = theDoc.AddImageObject(theImg, false);

theID = theDoc.GetInfoInt(theID, "XObject");
theDoc.SetInfo(theID, "Grayscale", "");

int theCS = theDoc.AddColorSpaceSpot("MAGENTA", "0 100 0 0");
theDoc.SetInfo(theID, "/ColorSpace:Ref", theCS.ToString());
theDoc.SetInfo(theID, "/Decode", "[1 0]");

theDoc.Save(Server.MapPath("doccolorspace.pdf"));
theDoc.Clear();

[Visual Basic]
Dim theDoc As Doc = New Doc()
theDoc.Rect.Inset(20, 20)

Dim theImg As XImage = New XImage()
theImg.SetFile(Server.MapPath("../mypics/mypic.jpg"))
Dim theID As Integer = theDoc.AddImageObject(theImg, False)

theID = theDoc.GetInfoInt(theID, "XObject")
theDoc.SetInfo(theID, "Grayscale", "")

Dim theCS As Integer = theDoc.AddColorSpaceSpot("MAGENTA", "0 100 0 0")
theDoc.SetInfo(theID, "/ColorSpace:Ref", theCS.ToString())
theDoc.SetInfo(theID, "/Decode", "[1 0]")

theDoc.Save(Server.MapPath("doccolorspace.pdf"))
theDoc.Clear()


doccolorspace.pdf