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

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

Introduction

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

Prototype

public SpotColor(PdfSpotColor spot, float tint) 

Source Link

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 o m*/

    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]);
}