SetColorSpaceType
IPDFDocument4 :: Page Operations :: Common

See Also Example
Collapse All

This method sets the type of the current color mapping profile for all stroke and fill operations.

Syntax

HRESULT SetColorSpaceType (
ColorSpaceType colorspace
)
Parameters
colorspace
New value for the current color mapping profile type

Return value
If successful, this method returns S_OK. If it fails, this method should return one of the error values.

Remarks

You may pass only these values as a parameter: cstDefaultGray, cstDefaultRGB, cstDefaultCMYK. Passing cstICCBasedRGB or cstICCBasedCMYK will do nothing. If you want to set the ICC based RGB or CMYK profile, then use the SetColorSpace method, and the color space type will be set automatically.

Example

Using Different Color Profiles

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.SetColorSpaceType(cstDefaultRGB);
PDF.SetColor(0.7, 0.3, 0.8, 0.2);
PDF.DrawRectangle(10, 10, 100, 100, 0);
PDF.FillAndStroke;

PDF.SetColorSpaceType(cstDefaultCMYK);
PDF.SetColor(0.7, 0.3, 0.8, 0.2);
PDF.DrawRectangle(10, 10, 100, 100, 0);
PDF.FillAndStroke;

PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->SetColorSpaceType(cstDefaultRGB);
PDF->SetColor(0.7f, 0.3f, 0.8f, 0.2f);
PDF->DrawRectangle(10, 10, 100, 100, 0);
PDF->FillAndStroke();

PDF->SetColorSpaceType(cstDefaultCMYK);
PDF->SetColor(0.7f, 0.3f, 0.8f, 0.2f);
PDF->DrawRectangle(10, 10, 100, 100, 0);
PDF->FillAndStroke();

PDF.SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF.SetColorSpaceType(ColorSpaceType.cstDefaultRGB);
PDF.SetColor(0.7f, 0.3f, 0.8f, 0.2f);
PDF.DrawRectangle(10, 10, 100, 100, 0);
PDF.FillAndStroke();

PDF.SetColorSpaceType(ColorSpaceType.cstDefaultCMYK);
PDF.SetColor(0.7f, 0.3f, 0.8f, 0.2f);
PDF.DrawRectangle(10, 10, 100, 100, 0);
PDF.FillAndStroke();

PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.SetColorSpaceType 1 'ColorSpaceType.cstDefaultRGB = 1
PDF.SetColor 0.7, 0.3, 0.8, 0.2
PDF.DrawRectangle 10, 10, 100, 100, 0
PDF.FillAndStroke

PDF.SetColorSpaceType 2 'ColorSpaceType.cstDefaultCMYK = 2
PDF.SetColor 0.7, 0.3, 0.8, 0.2
PDF.DrawRectangle 10, 120, 100, 100, 0
PDF.FillAndStroke

PDF.SaveToFile "test.pdf", true

See Also

Reference