Class: ColorSpace

PDFNet. ColorSpace


new ColorSpace()

This abstract class is used to serve as a color space tag to identify the specific color space of a Color object. It contains methods that transform colors in a specific color space to/from several color space such as DeviceRGB and DeviceCMYK.

For purposes of the methods in this class, colors are represented as arrays of color components represented as doubles in a normalized range defined by each ColorSpace. For many ColorSpaces (e.g. DeviceRGB), this range is 0.0 to 1.0. However, some ColorSpaces have components whose values have a different range. Methods are provided to inquire per component minimum and maximum normalized values.

Methods


<static> create(color_space)

Create a ColorSpace from the given SDF/Cos object listed under ColorSpaces entry in page Resource dictionary. If color_space dictionary is null, a non valid ColorSpace object is created.

Parameters:
Name Type Description
color_space PDFNet.Obj

The Cos/SDF object to initialze the ColorSpace object with.

Returns:

A promise that resolves to an object of type: "ColorSpace"

Type
PDFNet.ColorSpace

<static> createDeviceCMYK()

Create a new DeviceCMYK ColorSpace object

Returns:

A promise that resolves to an object of type: "ColorSpace"

Type
PDFNet.ColorSpace

<static> createDeviceGray()

Create a new DeviceGray ColorSpace object

Returns:

A promise that resolves to an object of type: "ColorSpace"

Type
PDFNet.ColorSpace

<static> createDeviceRGB()

Create a new DeviceRGB ColorSpace object

Returns:

A promise that resolves to an object of type: "ColorSpace"

Type
PDFNet.ColorSpace

<static> createICCFromBuffer(doc, buf)

Parameters:
Name Type Description
doc PDFNet.SDFDoc
buf Array
Returns:

A promise that resolves to an object of type: "ColorSpace"

Type
PDFNet.ColorSpace

<static> createICCFromFilter(doc, filter)

Parameters:
Name Type Description
doc PDFNet.SDFDoc
filter PDFNet.Filter
Returns:

A promise that resolves to an object of type: "ColorSpace"

Type
PDFNet.ColorSpace

<static> createPattern()

Create a new Pattern ColorSpace object

Returns:

A promise that resolves to an object of type: "ColorSpace"

Type
PDFNet.ColorSpace

<static> getComponentNumFromObj(cs_type, cs_obj)

Parameters:
Name Type Description
cs_type number
cs_obj PDFNet.Obj

Cos/SDF color space object.

Returns:

A promise that resolves to the number of components (tint components) used to represent color point for this color space

Type
number

<static> getTypeFromObj(cs_obj)

Parameters:
Name Type Description
cs_obj PDFNet.Obj

Cos/SDF color space object.

Returns:

A promise that resolves to the Type of a given SDF/Cos color space, or e_null for if SDF object is not a valid color space

Type
number
Example
Return value enum:
<pre>
PDFNet.ColorSpace.Type = {
	e_device_gray : 0
	e_device_rgb : 1
	e_device_cmyk : 2
	e_cal_gray : 3
	e_cal_rgb : 4
	e_lab : 5
	e_icc : 6
	e_indexed : 7
	e_pattern : 8
	e_separation : 9
	e_device_n : 10
	e_null : 11
}
</pre>

assign(right)

Copy Constructor

Parameters:
Name Type Description
right PDFNet.ColorSpace

convert2CMYK(in_color)

A convenience function used to convert color points from the current color space to DeviceCMYK color space.

Parameters:
Name Type Description
in_color PDFNet.colorpt

input color point in the current color space


convert2Gray(in_color)

A convenience function used to convert color points from the current color space to DeviceGray color space.

Parameters:
Name Type Description
in_color PDFNet.colorpt

input color point in the current color space


convert2RGB(in_color)

A convenience function used to convert color points from the current color space to DeviceRGB color space.

Parameters:
Name Type Description
in_color PDFNet.colorpt

input color point in the current color space


destroy()

Frees the native memory of the object.


getAlternateColorSpace()

Returns:

A promise that resolves to the alternate color space if it is available or NULL otherwise. Color spaces that include alternate color space are e_separation, e_device_n, and e_icc.

Type
PDFNet.ColorSpace

getBaseColor(color_idx)

Get the base color given a component value (index) in Indexed color space.

Parameters:
Name Type Description
color_idx number

color value represented in the index color space


getBaseColorSpace()

Returns:

A promise that resolves to the base color space if this is an e_indexed or e_pattern with associated base color space; NULL otherwise.

Type
PDFNet.ColorSpace

getComponentNum()

Returns:

A promise that resolves to the number of colorants (tint components) used to represent color point in this color space

Type
number

getHighVal()

Returns:

A promise that resolves to the highest index for the color lookup table for Indexed color space. Since the color table is indexed from zero to highval, the actual number of entries is highval + 1. For color spaces other than indexed the method returns 0.

Type
number

getLookupTable()

Returns:

A promise that resolves to the color lookup table for Indexed color space. for color spaces other than indexed the method returns NULL.

Type
number

getSDFObj()

Returns:

A promise that resolves to the underlying SDF/Cos object

Type
PDFNet.Obj

getTintFunction()

Returns:

A promise that resolves to the function that transforms tint values into color component values in the alternate color space.

Type
PDFNet.Function

getType()

Returns:

A promise that resolves to the type of this color space

Type
number
Example
Return value enum:
<pre>
PDFNet.ColorSpace.Type = {
	e_device_gray : 0
	e_device_rgb : 1
	e_device_cmyk : 2
	e_cal_gray : 3
	e_cal_rgb : 4
	e_lab : 5
	e_icc : 6
	e_indexed : 7
	e_pattern : 8
	e_separation : 9
	e_device_n : 10
	e_null : 11
}
</pre>

initColor()

Set color to the initial value used for this color space. The initial value depends on the color space (see 4.5.7 in PDF Ref. Manual).


initComponentRanges(num_comps)

Parameters:
Name Type Description
num_comps number

isAll()

Returns:

A promise that resolves to true if Separation color space contains the colorant All.

Type
boolean

isNone()

Returns:

A promise that resolves to true if Separation or DeviceN color space contains None colorants. For DeviceN the function returns true only if component colorant names are all None.

Type
boolean