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.
Note: Note that in Pattern color space (i.e. for PDFNet.ColorSpace.Type.e_pattern) 'color values'
are PDFNet.PatternColor objects instead of the numeric component values (i.e. ColorPt)
used with other spaces.
Extends
Members
-
<static> Type
-
Properties:
Name Type Description e_device_gray
number e_device_rgb
number e_device_cmyk
number e_cal_gray
number e_cal_rgb
number e_lab
number e_icc
number e_indexed
number e_pattern
number e_separation
number e_device_n
number e_null
number
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 Argument Description color_space
Core.PDFNet.Obj <optional>
The Cos/SDF object to initialze the ColorSpace object with. Returns:
A promise that resolves to an object of type: "PDFNet.ColorSpace"- Type
- Promise.<Core.PDFNet.ColorSpace>
-
<static> createDeviceCMYK()
-
Create a new DeviceCMYK ColorSpace object
Returns:
A promise that resolves to an object of type: "PDFNet.ColorSpace"- Type
- Promise.<Core.PDFNet.ColorSpace>
-
<static> createDeviceGray()
-
Create a new DeviceGray ColorSpace object
Returns:
A promise that resolves to an object of type: "PDFNet.ColorSpace"- Type
- Promise.<Core.PDFNet.ColorSpace>
-
<static> createDeviceRGB()
-
Create a new DeviceRGB ColorSpace object
Returns:
A promise that resolves to an object of type: "PDFNet.ColorSpace"- Type
- Promise.<Core.PDFNet.ColorSpace>
-
<static> createICCFromBuffer(doc, buf)
-
Parameters:
Name Type Description doc
Core.PDFNet.PDFDoc | Core.PDFNet.SDFDoc | Core.PDFNet.FDFDoc buf
ArrayBuffer | Int8Array | Uint8Array | Uint8ClampedArray Returns:
A promise that resolves to an object of type: "PDFNet.ColorSpace"- Type
- Promise.<Core.PDFNet.ColorSpace>
-
<static> createICCFromFilter(doc, filter)
-
Parameters:
Name Type Description doc
Core.PDFNet.PDFDoc | Core.PDFNet.SDFDoc | Core.PDFNet.FDFDoc filter
Core.PDFNet.Filter Returns:
A promise that resolves to an object of type: "PDFNet.ColorSpace"- Type
- Promise.<Core.PDFNet.ColorSpace>
-
<static> createPattern()
-
Create a new Pattern ColorSpace object
Returns:
A promise that resolves to an object of type: "PDFNet.ColorSpace"- Type
- Promise.<Core.PDFNet.ColorSpace>
-
<static> getComponentNumFromObj(cs_type, cs_obj)
-
Parameters:
Name Type Description cs_type
number 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 }
The color space type.cs_obj
Core.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
- Promise.<number>
-
<static> getTypeFromObj(cs_obj)
-
Parameters:
Name Type Description cs_obj
Core.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
- Promise.<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>
-
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
Core.PDFNet.ColorPt input color point in the current color space Note: the number to input colorants must match the number of colorants expected by the current color space. Returns:
A promise that resolves to an object of type: "PDFNet.ColorPt"- Type
- Promise.<Core.PDFNet.ColorPt>
-
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
Core.PDFNet.ColorPt input color point in the current color space Note: the number to input colorants must match the number of colorants expected by the current color space. Returns:
A promise that resolves to an object of type: "PDFNet.ColorPt"- Type
- Promise.<Core.PDFNet.ColorPt>
-
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
Core.PDFNet.ColorPt input color point in the current color space Note: the number to input colorants must match the number of colorants expected by the current color space. Returns:
A promise that resolves to an object of type: "PDFNet.ColorPt"- Type
- Promise.<Core.PDFNet.ColorPt>
-
destroy()
-
Destructor
- Inherited From:
Returns:
- Type
- Promise.<void>
-
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
- Promise.<Core.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 Note: for color spaces other than Indexed this method throws an exception. Returns:
A promise that resolves to an object of type: "PDFNet.ColorPt"- Type
- Promise.<Core.PDFNet.ColorPt>
-
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
- Promise.<Core.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
- Promise.<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. Note: for color spaces other than Indexed this method throws an exception.- Type
- Promise.<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. Note: for color spaces other than Indexed this method throws an exception.- Type
- Promise.<number>
-
getSDFObj()
-
Returns:
A promise that resolves to the underlying SDF/Cos object- Type
- Promise.<Core.PDFNet.Obj>
-
getTintFunction()
-
Returns:
A promise that resolves to the function that transforms tint values into color component values in the alternate color space. Note: for color spaces other than Separation this method throws an exception.- Type
- Promise.<Core.PDFNet.Function>
-
getType()
-
Returns:
A promise that resolves to the type of this color space- Type
- Promise.<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).
Returns:
A promise that resolves to an object of type: "PDFNet.ColorPt"- Type
- Promise.<Core.PDFNet.ColorPt>
-
initComponentRanges(num_comps)
-
Parameters:
Name Type Description num_comps
number Returns:
A promise that resolves to an object of type: "Object"- Type
- Promise.<Object>
-
isAll()
-
Returns:
A promise that resolves to true if Separation color space contains the colorant All. Note: for color spaces other than Separation this method throws an exception.- Type
- Promise.<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. Note: for color spaces other than Separation or DeviceN this method throws an exception.- Type
- Promise.<boolean>
-
takeOwnership()
-
Take the ownership of this object, so that PDFNet.runWithCleanup won't destroy this object.
- Inherited From:
Returns:
- Type
- void