API referenceGraphics

pdfSetColorSpace

Select the current color space for both fill and stroke in

C
BOOL32 __stdcall pdfSetColorSpace(PPDF IPDF, int32_t ColorSpace);
Delphi
function pdfSetColorSpace(const IPDF: PPDF; ColorSpace: Integer): LongBool; stdcall;

Purpose. Select the current color space for both fill and stroke in one call, with validation.

Description. Validates ColorSpace before accepting it: rejects negative values outright; if ColorSpace >= CS_HANDLE_BASE (3), it must resolve to a live registered color space via FindCSByHandle (an unknown or already-deleted handle fails); if ColorSpace is in the reserved range below CS_HANDLE_BASE it must be one of the three device ordinals (0=RGB, 1=CMYK, 2=Gray) — ColorSpace = 3.. bypassing the handle check would otherwise be accepted as garbage. On success, sets FFillCS := ColorSpace and FStrokeCS := ColorSpace atomically.

Parameters.

ParameterDescription
IPDFDocument handle.
ColorSpaceA device ordinal (0/1/2) or a registered color-space handle (>= CS_HANDLE_BASE).

Return value. True if ColorSpace was valid and applied to both fill and stroke; False on validation failure (invalid ordinal or unknown/dead handle) — in that case neither FFillCS nor FStrokeCS is modified.

Remarks. This is the *validated* entry point. Compare with pdfSetFillColorSpace/pdfSetStrokeColorSpace below, which set only one side each and perform no validation at all.

See also. pdfSetFillColorSpace, pdfGetColorSpace.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Graphics
Category

Setters

Exported names

pdfSetColorSpace

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.