I want to paint some Graphics2D objects, using java printing mechanism. So i have to define a subclass of Printable.
public class PrintCMYK() implements Printable {
public int print(Graphics g, PageFormat pf, int page)
throws PrinterException {
g.setColor(Color.RED);
g.fillOval(44, 44, 100, 100);
}
}
So this code just prints a red rgb circle. Java probably converts somehow rgb color in some CMYK, to be able to print it with CMYK. But i want a full control here. So can i somehow explicit set wanted CMYK color. Something like
public class PrintCMYK() implements Printable {
public int print(Graphics g, PageFormat pf, int page)
throws PrinterException {
float[] ff = {0, 1, 0, 0}; // pure magenta
Color cmykColor = new Color(ColorSpace.getInstance(TYP_CMYK), ff, 1);
g.setPaint(cmykColor);
g.fillOval(44, 44, 100, 100);
}
}
This code does not work unfortunately.
UPD: In Postscript produces by java code used instruction setrgbcolor but i need setcmykcolor. Can i achieve this behavior somehow?