FULL PRODUCT VERSION :
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
Printer = HP DeskJet 6127
A DESCRIPTION OF THE PROBLEM :
It turns out that our Java application prints just fine under Java 1.1, 1.3, 1.4, but not 1.5. From what I can tell, under Java 1.5.x, printing to an HP 6127 printer results in output that about 50% smaller than it should be.
Additional testing to the "Microsoft Office Document Image Writer" printer (to a TIFF file), shows that once again, everything works from Java 1.4 (I get a red box on the page as expected), but in Java 1.5, the TIFF is 'wrong' (the box is black/white with stripes instead of a red box).
So it appears that the attached test case demonstrates a huge bug in the printing subsystem of Java 1.5.x
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached program and allow it to print to an HP 6127 printer.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Java 1.4.2: A 1" red square printed, positioned at X 1", Y 1".
HP 6127:
http://www.duckware.com/bugs/printjob/pj142hp.gif
Microsoft Office Document Image Writer:
http://www.duckware.com/bugs/printjob/pj142ms.gif
ACTUAL -
Java 1.5.x:
HP 6127:
A 0.5" red square printed, positioned at X 0.625", Y 0.5"
http://www.duckware.com/bugs/printjob/pj150hp.gif
Microsoft Office Document Image Writer:
A striped black/white square (not red)
http://www.duckware.com/bugs/printjob/pj150ms.gif
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
public class PrintJobBug {
public static void main( String args[] ) {
Frame f = new Frame();
f.show();
PrintJob pjob = f.getToolkit().getPrintJob(f, "bug", null);
if (pjob!=null) {
int dpi = pjob.getPageResolution();
System.out.println( "dpi="+dpi);
Image i = f.createImage(dpi,dpi);
if (true) {
Graphics g = i.getGraphics();
g.setColor( Color.red );
g.fillRect( 0, 0, dpi, dpi );
}
Graphics g = pjob.getGraphics();
g.drawImage( i, dpi, dpi, null );
pjob.end();
}
System.exit(0);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None. Printing from our app in Java 1.5.x is totally busted, which the attach code demonstrates.