FULL PRODUCT VERSION :
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
When using PrinterJob.pageDialog() to get a PageFormat object, if the page size and margins are set with the default printer selected (in the "Printer" dialog), it behaves correctly. But when another printer is selected and a specific page format chosen, the returned imageableWidth and imageableHeight values of the PageFormat object are incorrect.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code below twice:
(1) with the desired printer set as default printer in the Windows Printer settings (so that no modification in the "Printer" dialog is necessary)
(2) with another printer set as default (so that changing the printer in the "Printer" dialog is necessary)
Select the same page size and margins for both runs.
Note that the selected printer is a HP DesignJet 500 42, which can print on very big page formats. Here the selected format was 1meter x 1.4 meter
Output for (1):
<beginning_of_output>
------- Page Format -------
ImageableX = 72.0
ImageableY = 72.0
ImageableWidth = 468.0
ImageableHeight = 648.0
Width = 612.0
Height = 792.0
------- Page Format -------
ImageableX = 72.0
ImageableY = 72.0
ImageableWidth = 2690.6456692913384
ImageableHeight = 3824.503937007874
Width = 2834.6456692913384
Height = 3968.503937007874
<end_of_output>
Output for (2):
<beginning_of_output>
------- Page Format -------
ImageableX = 72.0
ImageableY = 72.0
ImageableWidth = 468.0
ImageableHeight = 648.0
Width = 612.0
Height = 792.0
------- Page Format -------
ImageableX = 72.0
ImageableY = 72.0
ImageableWidth = 522.0
ImageableHeight = 707.9811023622048
Width = 2834.6456692913384
Height = 3968.503937007874
<end_of_output>
Code:
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The output should be the same, i.e. the imageableHeight and imageableWidth should be the same for both runs.
ACTUAL -
imageableHeight and imageableWidth differ between the two runs.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.print.PageFormat;
import java.awt.print.PrinterJob;
public class TestProg
{
public static void main(String[] args)
{
PageFormat pf = new PageFormat();
displayPageFormat(pf);
pf = PrinterJob.getPrinterJob().pageDialog(new PageFormat());
displayPageFormat(pf);
}
public static void displayPageFormat(PageFormat pf)
{
System.out.println("------- Page Format -------");
System.out.println("ImageableX = " + pf.getImageableX());
System.out.println("ImageableY = " + pf.getImageableY());
System.out.println("ImageableWidth = " + pf.getImageableWidth());
System.out.println("ImageableHeight = " + pf.getImageableHeight());
System.out.println("Width = " + pf.getWidth());
System.out.println("Height = " + pf.getHeight());
}
}
---------- END SOURCE ----------