API referenceGraphics

pdfCreateICCBasedColorSpaceEx

Register a new ICCBased color space, either loading the ICC

C
int32_t __stdcall pdfCreateICCBasedColorSpaceA(PPDF IPDF, const char* ICCProfile);
int32_t __stdcall pdfCreateICCBasedColorSpaceW(PPDF IPDF, const wchar_t* ICCProfile);
int32_t __stdcall pdfCreateICCBasedColorSpaceEx(PPDF IPDF, void* Buffer, uint32_t BufSize);
Delphi
function pdfCreateICCBasedColorSpaceA(const IPDF: PPDF; const ICCProfile: PAnsiChar): Integer; stdcall;
function pdfCreateICCBasedColorSpaceW(const IPDF: PPDF; const ICCProfile: PWideChar): Integer; stdcall;
function pdfCreateICCBasedColorSpaceEx(const IPDF: PPDF; Buffer: Pointer; BufSize: Cardinal): Integer; stdcall;

Purpose. Register a new ICCBased color space, either loading the ICC profile from a file path (A/W) or from an in-memory buffer (Ex).

Description. A/W load the whole profile file into memory (LoadFileBytes, silently returning -1 on any I/O failure — missing file, access denied, empty file — with no distinct error code) and then delegate to Ex. Ex first inspects the profile header via ICCProfileInfo to derive the component count (N, 1/3/4) and a coarse alternate device space guess (Alt), then registers a cskICCBased entry via CreateICCBasedColorSpace (which itself rejects NumComps outside 1..4 or an empty/null buffer) and copies the raw profile bytes verbatim into the color-space entry's Profile field — the profile is stored as-is, not re-parsed or validated beyond the header sniff.

Parameters.

ParameterDescription
IPDFDocument handle.
ICCProfile*(A/W)* Path to an .icc/.icm profile file.
Buffer / BufSize*(Ex)* In-memory ICC profile bytes and length.

Return value. The new color-space handle (>= CS_HANDLE_BASE) on success; -1 on any failure (file not found/unreadable, null/empty buffer, or a component count outside 1-4 as sniffed from the profile header).

See also. pdfGetColorSpaceObj (read back ColorSpaceType/Alternate).

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfCreateICCBasedColorSpaceEx(IntPtr IPDF, IntPtr Buffer, uint BufSize);
Area
Graphics
Category

Object Creation

Exported names

pdfCreateICCBasedColorSpaceEx

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.