-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b14
-
x86
-
windows_xp
-
Verified
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The PrinterJob native pageDialog miscalculates the PageFormat ImageableWidth after switching from PORTRAIT to LANDSCAPE for printers with different minimum top and bottom margins.
What should happen (and did prior to 1.5.0), is that the new left margin should be the old top margin and the new right margin should be the old bottom margin. This is what it shows in the Page Setup dialog GUI. But the PageFormat returned by the pageDialog has both the new left and right margins equal to the old, larger bottom margin. The new ImageableWidth should be identical to the old ImageableHeight, but instead is smaller. If you have more generous margins, the problem doesn't show but at the minimum margin settings, the new PageFormat incorrectly enforces the larger of the minimum top and bottom margins on both the new left and right margins.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and build program provided below
Run on a system where the default printer has different minimum top and bottom margins. For example, I'm using an HP OfficeJet G85.
The first Page Setup dialog will come up showing the minimum margins. Hit OK to print out these minimum margins.
A second Page Setup dialog will come up. Select Landscape and note the changed margins. Now hit OK and compare the second ouptut to the first output, in particular note the incorrect margins and the new ImageableWidth not equal to the old ImageableHeight.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Here's the result on 1.4.2 for an HP OfficeJet G85:
before:
HWO: 792.0 612.0 1
iHWXY: 753.84 576.0 18.0 5.04
LRTB: 18.0 18.0 5.04 33.11999999999997
after:
HWO: 612.0 792.0 0
iHWXY: 576.0 753.84 33.120000000000005 18.0
LRTB: 33.120000000000005 5.039999999999964 18.0 18.0
ACTUAL -
Here's the result on 1.5.0 for the same printer:
before:
HWO: 792.0 612.0 1
iHWXY: 753.84 576.0 18.0 5.04
LRTB: 18.0 18.0 5.04 33.11999999999997
after:
HWO: 612.0 792.0 0
iHWXY: 576.0 725.76 33.120000000000005 18.0
LRTB: 33.120000000000005 33.120000000000005 18.0 18.0
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.print.*;
public class Test {
static public void main(String args[]) {
PrinterJob pj = PrinterJob.getPrinterJob();
PageFormat pf = pj.defaultPage();
Paper paper = new Paper();
paper.setImageableArea(0.0, 0.0, pf.getWidth(), pf.getHeight());
paper.setSize(pf.getWidth(), pf.getHeight());
pf.setPaper(paper);
pf.setOrientation(PageFormat.PORTRAIT);
pf = pj.pageDialog(pf); // just say OK
// now we have the minimum margins
System.out.println("\nbefore:");
printPageFormat(pf);
PageFormat newpf = pj.pageDialog(pf); // switch to landscape, say OK
System.out.println("\nafter:");
printPageFormat(newpf); // imageableWidth is wrong
}
static void printPageFormat(PageFormat pf) {
double pLM = pf.getImageableX();
double pTM = pf.getImageableY();
double pRM = pf.getWidth() - pf.getImageableWidth() - pLM;
double pBM = pf.getHeight() - pf.getImageableHeight() - pTM;
double pH = pf.getHeight();
double pW = pf.getWidth();
int orientation = pf.getOrientation();
System.out.println("HWO: " + pH + " " + pW + " " + orientation);
System.out.println("iHWXY: " + pf.getImageableHeight()
+ " " + pf.getImageableWidth()
+ " " + pf.getImageableX() + " " + pf.getImageableY());
System.out.println("LRTB: " + pLM + " " + pRM + " " + pTM + " " + pBM);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Workarounds:
1) Revert to 1.4.2
2) Use more generous margins
3) Use the cross-platform dialog, which appears to be OK.
Release Regression From : 1.3.1
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
###@###.### 2005-2-15 19:30:21 GMT
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The PrinterJob native pageDialog miscalculates the PageFormat ImageableWidth after switching from PORTRAIT to LANDSCAPE for printers with different minimum top and bottom margins.
What should happen (and did prior to 1.5.0), is that the new left margin should be the old top margin and the new right margin should be the old bottom margin. This is what it shows in the Page Setup dialog GUI. But the PageFormat returned by the pageDialog has both the new left and right margins equal to the old, larger bottom margin. The new ImageableWidth should be identical to the old ImageableHeight, but instead is smaller. If you have more generous margins, the problem doesn't show but at the minimum margin settings, the new PageFormat incorrectly enforces the larger of the minimum top and bottom margins on both the new left and right margins.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and build program provided below
Run on a system where the default printer has different minimum top and bottom margins. For example, I'm using an HP OfficeJet G85.
The first Page Setup dialog will come up showing the minimum margins. Hit OK to print out these minimum margins.
A second Page Setup dialog will come up. Select Landscape and note the changed margins. Now hit OK and compare the second ouptut to the first output, in particular note the incorrect margins and the new ImageableWidth not equal to the old ImageableHeight.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Here's the result on 1.4.2 for an HP OfficeJet G85:
before:
HWO: 792.0 612.0 1
iHWXY: 753.84 576.0 18.0 5.04
LRTB: 18.0 18.0 5.04 33.11999999999997
after:
HWO: 612.0 792.0 0
iHWXY: 576.0 753.84 33.120000000000005 18.0
LRTB: 33.120000000000005 5.039999999999964 18.0 18.0
ACTUAL -
Here's the result on 1.5.0 for the same printer:
before:
HWO: 792.0 612.0 1
iHWXY: 753.84 576.0 18.0 5.04
LRTB: 18.0 18.0 5.04 33.11999999999997
after:
HWO: 612.0 792.0 0
iHWXY: 576.0 725.76 33.120000000000005 18.0
LRTB: 33.120000000000005 33.120000000000005 18.0 18.0
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.print.*;
public class Test {
static public void main(String args[]) {
PrinterJob pj = PrinterJob.getPrinterJob();
PageFormat pf = pj.defaultPage();
Paper paper = new Paper();
paper.setImageableArea(0.0, 0.0, pf.getWidth(), pf.getHeight());
paper.setSize(pf.getWidth(), pf.getHeight());
pf.setPaper(paper);
pf.setOrientation(PageFormat.PORTRAIT);
pf = pj.pageDialog(pf); // just say OK
// now we have the minimum margins
System.out.println("\nbefore:");
printPageFormat(pf);
PageFormat newpf = pj.pageDialog(pf); // switch to landscape, say OK
System.out.println("\nafter:");
printPageFormat(newpf); // imageableWidth is wrong
}
static void printPageFormat(PageFormat pf) {
double pLM = pf.getImageableX();
double pTM = pf.getImageableY();
double pRM = pf.getWidth() - pf.getImageableWidth() - pLM;
double pBM = pf.getHeight() - pf.getImageableHeight() - pTM;
double pH = pf.getHeight();
double pW = pf.getWidth();
int orientation = pf.getOrientation();
System.out.println("HWO: " + pH + " " + pW + " " + orientation);
System.out.println("iHWXY: " + pf.getImageableHeight()
+ " " + pf.getImageableWidth()
+ " " + pf.getImageableX() + " " + pf.getImageableY());
System.out.println("LRTB: " + pLM + " " + pRM + " " + pTM + " " + pBM);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Workarounds:
1) Revert to 1.4.2
2) Use more generous margins
3) Use the cross-platform dialog, which appears to be OK.
Release Regression From : 1.3.1
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
###@###.### 2005-2-15 19:30:21 GMT
- relates to
-
JDK-4694478 REGRESSION: pageDialog() mixes up margins for some printers in landscape
-
- Resolved
-
-
JDK-6228728 DOC : Java will not print in landscape mode using drawImage.
-
- Resolved
-