Class SpotColorSpace

  • All Implemented Interfaces:
    Serializable

    public final class SpotColorSpace
    extends DeviceNColorSpace

    A type of ColorSpace dealing with Separation ("Spot") Colors.

    Spot colors are used to define an exact color in the printed output. This is usually done by printing these colors using a matching ink onto a separate film, ink which may be outside the gamut of the normal CMYK printing process. Commonly used Spot colors include those from the PANTONE™ and Focoltone™ range of colors.

    Every Spot colorspace has a name, which is the name used by the printer to identify the ink. Because not every output device may have the specified ink available (displaying the PDF on screen for example), every Spot color must have a "fallback" color specified as a process color (RGB, CMYK or Lab) as well. Remembering that not every spot color can be reproduced in CMYK, the fallback color is often just a close match unless a Lab color is used.

    Like normal colorspaces (RGB, CMYK and so on), different colors can be specified within this space, although they will all be just a different intensity of the specified ink - ranging from zero (no ink is applied) to one (the full intensity of the specified color is applied).

    Here's an example showing how to use the PANTONE™ color "PANTONE Reflex Blue" to print a line of text.

       Color fallback = CYMKColorSpace.getColor(1.0, 0.72, 0, 0.06);
       SpotColorSpace blueink = new SpotColorSpace("PANTONE Reflex Blue CVC", fallback);
       Color logoblue = blueink.getColor(1);
    
       PDFStyle style = new PDFStyle();
       style.setFillColor(logoblue);
       page.setStyle(style);
       page.drawText("This is in PANTONE Reflex Blue CVC", 100, 100);
     

    Note the three stages. First we create the fallback color, specified in CMYK. As it happens this spot color is outside the gamut of the CMYK colorspace, so our fallback is an approximation only. Then we create the colorspace, and finally we select a color which is this ink at 100% intensity. From there we can just use the color as normal.

    Registration Colors

    The special color "All" can be used to create a "registration color" - objects drawn in this color will appear on all plates, including the process color plates, and this feature is commonly used for printer marks.

    In the PDF specification Spot color is referred to as a "Separation" color.

    Since:
    1.1.5
    • Constructor Detail

      • SpotColorSpace

        public SpotColorSpace​(String name,
                              Color color)
        Create a new SpotColorSpace representing a single custom ink.
        Parameters:
        name - the name of the ink
        color - the color to use as a fallback color if this ink is not available. Must be from either an RGB, CMYK or Grayscale ColorSpace, or an IllegalArgumentException is thrown.
    • Method Detail

      • toRGB

        public int[] toRGB​(int[] in,
                           int[] out,
                           int intent)
      • getName

        public String getName()
        Get the name of this ColorSpace (which is the name of the Ink)
      • getColor

        public Color getColor()
        A convenience method returning the color specified by the full intensity of this colorspace. Equivalent to getColor(1).
      • getColor

        public Color getColor​(float amt)
        A convenience method to return a color from this ColorSpace.
        Parameters:
        amt - The intensity of the color. Any value between zero and one, where zero means no ink at all and one means the full intensity. If the number is outside this range, an IllegalArgumentException is thrown
        Throws:
        IllegalArgumentException
      • getColor

        public Color getColor​(float amt,
                              float alpha)
        A convenience method to return a color from this ColorSpace.
        Parameters:
        amt - The intensity of the color. Any value between zero and one, where zero means no ink at all and one means the full intensity. If the number is outside this range, an IllegalArgumentException is thrown
        alpha - the alpha value of this color - 0 meaning transparent, 1 meaning opaque. If the number is outside this range, an IllegalArgumentException is thrown
        Throws:
        IllegalArgumentException
        Since:
        2.0.5
      • getComponentColorSpace

        public SpotColorSpace getComponentColorSpace​(int component)
        Description copied from class: DeviceNColorSpace
        Get the Component ColorSpace for an individual spot color in the ColorSpace. Note that prior to 2.28.4 this method returned null for process components, which is no longer the case.
        Overrides:
        getComponentColorSpace in class DeviceNColorSpace
        Parameters:
        component - the component index