Example usage for com.itextpdf.text.pdf PdfSpotColor PdfSpotColor

List of usage examples for com.itextpdf.text.pdf PdfSpotColor PdfSpotColor

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfSpotColor PdfSpotColor.

Prototype


public PdfSpotColor(String name, BaseColor altcs) 

Source Link

Document

Constructs a new PdfSpotColor.

Usage

From source file:se.billes.pdf.renderer.request.factory.ColorFactory.java

License:Open Source License

public BaseColor createBaseColor(Color color) throws CreateColorException {
    if (color.getColor().length < 4 && color.getColor().length > 5) {
        throw new CreateColorException(
                "Incorrect length of color. Should be [cyan,magenta,yellow,black] or [cyan,magenta,yellow,black,tint]");
    }//from   w  w  w  . ja  v  a2 s . c  om

    if (color.getRef() == null) {
        throw new CreateColorException("You must specify a reference");
    }

    for (float c : color.getColor()) {
        if (c > 1 || c < 0) {
            throw new CreateColorException(
                    "[cyan,magenta,yellow,black] or [cyan,magenta,yellow,black,tint] must be between 0 and 1");
        }
    }
    float[] colors = color.getColor();
    CMYKColor baseColor = new CMYKColor(colors[0], colors[1], colors[2], colors[3]);
    if (color.getColor().length == 4) {
        return baseColor;
    }

    return new SpotColor(new PdfSpotColor(color.getRef(), baseColor), colors[4]);
}