AddColorSpace
IPDFDocument4 :: Page Operations :: Common

See Also Example
Collapse All

This method loads an ICC profile into a PDF document.

Syntax

LONG AddColorSpace (
BSTR colorspaceFile
)
Parameters
colorspaceFile
Path to a file containing an ICC profile

Return value
Index of the profile

Remarks

This method loads an ICC profile from a file colorspaceFile into a PDF document and returns the index of the profile. This index can be used later with color-related methods. Supported ICC profile types: RGB, CMYK.

The returned value can be used in SetColorSpace.

Example

How to Load a Colorspace and Set It to a PDF Document

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.SetLicenseData('demo', 'demo');
PDF.SetColorFill(1, 0, 0.5, 0); //this is standart RGB color
PDF.DrawRectangle(10, 10, 100, 100, 0);
PDF.Fill;

profile := PDF.AddColorSpace('path\to\AppleRGB.icc');
PDF.SetColorSpace(profile);
PDF.SetColorFill(1, 0, 0.5, 0); //this is a color from profile
PDF.DrawRectangle(130, 10, 100, 100, 0);
PDF.Fill;

PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->SetLicenseData("demo", "demo");
PDF->SetColorFill(1f, 0f, 0.5f, 0f); //this is standart RGB color
PDF->DrawRectangle(10, 10, 100, 100, 0);
PDF->Fill();

long profile = PDF->AddColorSpace("path\\to\\AppleRGB.icc");
PDF->SetColorSpace(profile);
PDF->SetColorFill(1f, 0f, 0.5f, 0f); //this is a color from profile
PDF->DrawRectangle(130, 10, 100, 100, 0);
PDF->Fill();

PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF.SetLicenseData("demo", "demo");
PDF.SetColorFill(1f, 0f, 0.5f, 0f); //this is standart RGB color
PDF.DrawRectangle(10, 10, 100, 100, 0);
PDF.Fill();

long profile = PDF.AddColorSpace(@"path\to\AppleRGB.icc");
PDF.SetColorSpace(profile);
PDF.SetColorFill(1f, 0f, 0.5f, 0f); //this is a color from profile
PDF.DrawRectangle(130, 10, 100, 100, 0);
PDF.Fill();

PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.SetLicenseData "demo", "demo"
PDF.SetColorFill 1, 0, 0.5, 0 'this is standart RGB color
PDF.DrawRectangle 10, 10, 100, 100, 0
PDF.Fill

profile = PDF.AddColorSpace("path\to\AppleRGB.icc")
PDF.SetColorSpace profile
PDF.SetColorFill 1, 0, 0.5, 0 'this is a color from profile
PDF.DrawRectangle 130, 10, 100, 100, 0
PDF.Fill

PDF.SaveToFile "test.pdf", true

See Also

Reference