pdfCreateDeviceNColorSpace
Register a new DeviceN color space with one or more named
int32_t __stdcall pdfCreateDeviceNColorSpace(PPDF IPDF, PPAnsiChar Colorants, uint32_t NumColorants, const char* PostScriptFunc, TExtColorSpace Alternate, int32_t Handle);
function pdfCreateDeviceNColorSpace(const IPDF: PPDF; Colorants: PPAnsiChar; NumColorants: Cardinal; const PostScriptFunc: PAnsiChar; Alternate: TExtColorSpace; Handle: Integer): Integer; stdcall;
Purpose. Register a new DeviceN color space with one or more named colorants and a PostScript tint-transform function.
Description. Requires a non-null Colorants array, NumColorants > 0, and a non-null PostScriptFunc; fails (-1) if any of those is missing. Reads NumColorants PAnsiChar entries from Colorants into an internal name array (a null entry becomes an empty string, not a failure). Maps Alternate the same coarse way as pdfChangeSeparationColor (previous chapter): 1→DeviceCMYK, 2→DeviceGray, anything else→DeviceRGB. The Handle parameter is accepted by the ABI but never read by the implementation — CreateDeviceNColorSpace always allocates a fresh handle via RegisterColorSpace; there is no way to force a caller-chosen handle number through this call despite the parameter's presence.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Colorants | Array of NumColorants colorant name strings. |
NumColorants | Number of colorants (must be > 0). |
PostScriptFunc | PostScript tint-transform function source (required, stored verbatim). |
Alternate | Device alternate space — only CMYK(1)/Gray(2) distinguished, else RGB. |
Handle | Accepted but ignored — a new handle is always auto-allocated. |
Return value. The new (auto-allocated) color-space handle on success; -1 if Colorants/NumColorants/PostScriptFunc requirements aren't met.
Remarks. Use pdfAddDeviceNSeparationsAttr/pdfAddDeviceNProcessAttr afterward to attach the /Separations/process-color attributes structure DeviceN spaces typically carry (not covered in this chapter — see the DeviceN attributes cluster).
See also. pdfChangeSeparationColor, pdfRenameSpotColor.
C# (P/Invoke)
public static extern int pdfCreateDeviceNColorSpace(IntPtr IPDF, IntPtr Colorants, uint NumColorants, [MarshalAs(UnmanagedType.LPStr)] string PostScriptFunc, TExtColorSpace Alternate, int Handle);
Object Creation
pdfCreateDeviceNColorSpace
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.