JDK-8007642 : Media Names on Java Print Do Not Match the Printer���s and Confuse Users
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: windows
  • CPU: generic
  • Submitted: 2013-02-06
  • Updated: 2014-02-12
  • Resolved: 2013-07-22
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 JDK 8
6u71 b01Fixed 7u60Fixed 8Fixed
Description
FULL PRODUCT VERSION :
JDK 6u31

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows OS

A DESCRIPTION OF THE PROBLEM :
Java cross-platform Page Setup and Print dialogs do not always list all media sizes supported a printer. For example, if a printer supports both "11x17" and "Tabloid" media sizes according to its printing preferences in the system, the mentioned Java dialogs will show only "Tabloid" media size. Although these two media sizes are of the same size 11in x 17in, some users can be confused with absence of the expected "11x17" size on one of the two Java dialogs.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Verify that there is a printer which supports the media sizes "11x17", "Tabloid" in the system.
2. Set the printer found in the step #1 as a default printer in the system.
3. Compile and run the provided source code.
4. Try to find "11x17" in the contents of "Media Size" combo box on the displayed Page Setup dialog.

REPRODUCIBILITY :
The bug is reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.print.*;
import javax.print.attribute.*;

public class PrintDialogExample implements Printable {
    public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
        if (page > 0) {
            return NO_SUCH_PAGE;
        }

        Graphics2D g2d = (Graphics2D)g;
        g2d.translate(pf.getImageableX(), pf.getImageableY());
        g.drawString("Test the print dialog!", 100, 100);
        return PAGE_EXISTS;
    }

    public static void main(String args[]) {
        HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        PrinterJob job = PrinterJob.getPrinterJob();
        if (job.getPrintService() != null) {
            PageFormat pf = job.pageDialog(aset);
            if (pf != null) {
                job.setPrintable(new PrintDialogExample(), pf);
            } else {
                job.setPrintable(new PrintDialogExample());
            }
            if (job.printDialog(aset)) {
                try {
                    job.print(aset);
                } catch (PrinterException pe) {
                    pe.printStackTrace();
                }
            }
        }
    }
}
---------- END SOURCE ----------
Comments
Verified
07-11-2013

Still reproducible with XPS Printer. 11x17 is not in paper size combo! Only Ledger and Tabloid. However 11x17 is present for PrimoPDF printer. Really strange. Fix failed??
05-11-2013

Migrated from 6u72.
27-09-2013

The label "noreg-hard" was added to this bug to indicate that it is impossible to create a regression test for this bug, because several different printer drivers should be installed on the host.
20-06-2013

Source code of the test case was corrected to make it support actual printing also. Actual printing should be involved in a process of verification of the fix for this bug, because it is important not only to be sure that a missed media size is displayed in the list of media sizes, but a document can be printed using this media size properly.
11-02-2013

The issue was successfully reproduced on JDK 6u38 b05, JDK 7u13 b20, JDK 8 b54. JDK's Page Setup dialog and Page Setup tab of JDK's cross-platform Print Dialog work consistently among all these 3 versions of JDK. The reason of this bug is the following. The method "sun.print.Win32PrintService.initMedia" receives a list of media sizes supported by a printer from the method "getMediaSizes". This list can contain several instances of "ledger" media size, which correspond, for example, to "ledger", "tabloid", "11x17" media sizes, because all three of them have the same physical size "11in x 17in". But because of the internal logic of the method "initMedia" processing media size names two "ledger" media sizes are matched with the correct media size names "Ledger", "Tabloid", while the third one does not match "11x17" media size name, since it does not exist in JDK, and is matched with "Ledger" media size name. After this operation the last pair of matches "ledger" <--> "Ledger" is considered as a duplicate and ignored by the algorithm, and as the result of the call to "initMedia" method "Media Size" combo box of "Page Setup" dialog does not contain "11x17" media size.
07-02-2013