The Color class represents all color formats supported by NoPoDoFo. All color values must be between 0.0 and 1.0
class Color {
constructor()
constructor(grey: number)
constructor(fromString: string)
constructor(red: number, green: number, blue: number)
constructor(cyan: number, magenta: number, yellow: number, black: number)
getColorStreamString(): string
isRGB(): boolean
isCMYK(): boolean
isGreyScale(): boolean
convertToGreyScale(): Color
convertToCMYK(): Color
convertToRGB(): Color
getGrey(): number
getRed(): number
getGreen(): number
getBlue(): number
getCyan(): number
getMagenta(): number
getYellow(): number
getBlack(): number
}
const color = new nopodofo.Color('magenta')
Create a color from a string. Valid string arguments are:
- single grey value, e.g. '0.5'
- named color, e.g. 'aquamarine'
- hex value, e.g. '#FF002A'
If the argument passed could not be parsed, Black is returned.
constructor(grey: number)
Create a new GreyScale Color
constructor(red:number, green: number, blue: number)
Create a new RGB Color
constructor(cyan: number, magenta: number, yellow: number, black: number)
Create a new CMYK Color
getColorStreamString()
Get the stream representation of this color. For use when writing directly to a PdfStream, such as a PdfField AppearanceStream.
isRGB(): boolean
Is the color in RGB format
isCMYK(): boolean
Is the color in CMYK format
isGreyScale(): boolean
Is the color in GreyScale format
convertToGreyScale(): Color
Get the current color converted to GreyScale
convertToCMYK(): Color
Get the current color converted to CMYK
convertToRGB(): Color
Get the current color converted to RGB
getGrey(): number
Get grey value
getRed(): number
Get red value
getGreen(): number
Get green value
getBlue(): number
Get blue value
getCyan(): number
Get cyan value
getMagenta(): number
Get magenta value
getYellow(): number
Get yellow value
getBlack(): number
Get black value