pdfCreateICCBasedColorSpace
Register a new ICCBased color space, either loading the ICC
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);
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.
| Parameter | Description |
|---|---|
IPDF | Document 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)
public static extern int pdfCreateICCBasedColorSpaceA(IntPtr IPDF, [MarshalAs(UnmanagedType.LPStr)] string ICCProfile);
public static extern int pdfCreateICCBasedColorSpaceW(IntPtr IPDF, [MarshalAs(UnmanagedType.LPWStr)] string ICCProfile);
Object Creation
pdfCreateICCBasedColorSpaceA
pdfCreateICCBasedColorSpaceW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.