JDK-6357932 : JDK 1.5 : printing is incorrectly scaled on HP 6122, 6127 Epson R200 and likely others
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 5.0,5.0u5,6
  • Priority: P5
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-12-01
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u14Fixed 7 b17Fixed
Related Reports
Duplicate :  
Duplicate :  
Description
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.

Comments
EVALUATION I just saw this with HP 6122 (almost the same as HP 6127) and Epson R200. The root of the problem is that when displaying the print dialog, the driver updates its DC to reflect new values of LOGPIXELSX, LOGPIXELSY etc but we do not make the required upcall : setCapabilities(env, printCtrl, pd.hDC); to inform java code of this, and so the transformation set up by Java is now incorrect/out of sync with the DC.
19-06-2007

EVALUATION there are at least two users reporting problems like this This one with HP 6127 and another with EPSON STYLUS PHOTO 1290 I also think that this is the same as the zooming reported in incident 549165 (added to this CR) on a Konica Minolta Magicolor 2300 DL I suspect this may also be related (the same problem?) as 5044030 : Drawing problem with printer graphics on certain printers where the problem was on a Tektronix Phaser 850 DP in which case any fix should be tested with all of these printers and test cases. I suspect but am not sure that we are munging the quality/DPI fields in the DEVMODE in some cases.
01-12-2005