"Print Image" Problem
Hi! My name is Adrian Luna, I am doing a proyect in JAVA where I need to print an image in a plotter.
I have had success when I print an image in a common printer using the class "PrinterJob" and "Book", but the plotter does not recieve the information.
In order to resolve the problem, I have to use the class "PrintJob" and the plotter replies very well. But now, there is a exception (Exception occurred during event dispatching: java.lang.IllegalArgumentException: invalid ColorModel) when I use the instruction:
"g.drawImage(imgPrint,(int)imgX,(int)imgY,(int)imgWidth,(int)imgHeight,Color.white,null);"
Thank you, I will be glad if you could help me.
***********************************************
This is the code:
PrintJob pj = toolkit.getPrintJob (this,"Print",properties);
if (pj != null)
{
Graphics g = pj.getGraphics();
pageDim = pj.getPageDimension();
double imgX = 0;
double imgY = 0;
double imgWidth = pageDim.width;
double imgHeight = pageDim.height;
imgX = centimetroToPixel((double)1.0);
imgY = imgX;
imgWidth -= ((double)2*imgX);
imgHeight -= ((double)2*imgY);
g.setColor(Color.white);
g.fillRect(0,0,(int)pageDim.width,(int)pageDim.height);
g.drawImage(imgPrint,(int)imgX,(int)imgY,(int)imgWidth,(int)imgHeight,Color.white,null);
g.dispose();
pj.end();
}
public double centimetroToPixel(double x)
{
return (double)((x*10*1224)/(double)431.8);
}
*********************************************

