Using color in PDF document
UniPDF allows for setting color for text, line, and many other elements.
The simplest way of using color in UniPDF is by using the predefined colors
blackColor := creator.ColorBlack whiteColor := creator.ColorWhite redColor := creator.ColorRed greenColor := creator.ColorGreen blueColor := creator.ColorGreen yellowColor := creator.ColorYellow
You can also defined your own color by using RGB or CMYK color model.
RGB Color
There's multiple way to define an RGB color
- ColorRGBFrom8bit
This function accept three parameters: red, green, and blue value.
Each is value must be between 0 - 255.
red := creator.ColorRGBFrom8bit(255, 0, 0)
- ColorRGBFromArithmetic
This function accept three parameters: red, green, and blue value.
Each is value must be between 0.0 - 1.0.
green := creator.ColorRGBFromArithmetic(0.0, 1.0, 0.0)
- ColorRGBFromHex
This function accept one parameter, which is a hex color code.
blue := creator.ColorRGBFromHex("#0000ff")
CMYK color
To define a CMYK color, this following function could be used
-
ColorCMYKFrom8bit
This function accepts four parameter: cyan, magenta, yellow, and black color value.
Each value must be between 0 - 100.
cyan := creator.ColorCMYKFrom8bit(100, 0, 0, 0)
-
ColorCMYKFromArithmetic
This function accepts four parameter: cyan, magenta, yellow, and black color value.
Each value must be between 0.0 - 1.0.magenta:= creator.ColorCMYKFromArithmetic(0.0, 1.0, 0.0, 0.0)