Skip to content

Colors#

The basic color type is

type Color struct {
    Space       Space
    Basecolor   string
    SpotcolorID int
    C           float64
    M           float64
    Y           float64
    K           float64
    R           float64
    G           float64
    B           float64
    A           float64
}

The base color is the name of a spot color, such as “pantone 135”. The spot color id must be a document wide unique int (only for use with spot colors).

There are a the following color spaces

type Space int
Name Description
ColorNone ColorNone represents an undefined color space
ColorRGB ColorRGB represents a color in RGB color space
ColorCMYK Color CMYK represents a color in CMYK color space
ColorGray ColorGray represents a gray space color.
ColorSpotcolor ColorSpotcolor represents a spot color.

These two methods return a string that is usable in the PDF, such as "0 0 1 RG":

func (col *Color) PDFStringStroking() string
func (col *Color) PDFStringNonStroking() string

Color profiles#

The two methods

func (d *PDFDocument) LoadDefaultColorprofile() (*ColorProfile, error)
func (d *PDFDocument) LoadColorprofile(filename string) (*ColorProfile, error)

return a color profile to be embedded into the PDF. The color profile “Coated FOGRA39” with the file name ISOcoated_v2_eci.icc is included in boxes and glue, so it can be used without loading this profile from an external file. If you load another color profile, you should provide the necessary fields in from profile struct.

type ColorProfile struct {
    Identifier string
    Registry   string
    Info       string
    Condition  string
    Colors     int
}

The String() method just returns the identifier:

func (cp *ColorProfile) String() string {
    return "color profile:" + cp.Identifier
}