-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.3.0
-
x86
-
windows_nt
Name: yyT116575 Date: 11/13/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
My HP DeskJet 930C prints no images from a PrinterJob. It does print fonts and
vector graphics without problems however. Other printers (like the DeskJet 850)
print without problems. I do not even get a blank page, I get nothing. I can
see the print job being spooled normally, but it look likes the printer decides
the whole page is blank, so it does not produce a page. When i disable the
drawImage(), the text prints fine.
The problem can be reproduced from the following code :
import java.awt.*;
import java.awt.image.*;
import java.awt.print.*;
public class Print implements Printable
{
private BufferedImage image;
static public void main(String[] args)
{
try {new Print();System.exit(0);} catch (Exception e) {e.printStackTrace
();System.exit(1);}
}
public Print() throws PrinterException
{
image = new BufferedImage(100,100,BufferedImage.TYPE_3BYTE_BGR);
Graphics2D graphics = image.createGraphics();
graphics.setPaint(Color.red);
graphics.fillRect(0,0,100,100);
graphics.dispose();
PrinterJob job = PrinterJob.getPrinterJob();
job.pageDialog(job.defaultPage());
job.printDialog();
job.setPrintable(this);
job.print();
System.out.println("FINISHED");
}
public int print(Graphics graphics,PageFormat pageFormat,int pageIndex)
throws PrinterException
{
System.out.println("PRINTING");
if (pageIndex>0) return Printable.NO_SUCH_PAGE;
graphics.setColor(Color.black);
graphics.setFont(new Font("Monospace",Font.PLAIN,12));
graphics.drawString("Hello",120,100);
graphics.drawImage(image,120,140,null);
return Printable.PAGE_EXISTS;
}
}
(Review ID: 112181)
======================================================================
- duplicates
-
JDK-4258020 Java 2D printing API : images are B&W on PCL printers on win95/98 only
-
- Closed
-