United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-8007642 : Media Names on Java Print Do Not Match the Printer???s and Confuse Users

Details
Type:
Bug
Submit Date:
2013-02-06
Status:
Closed
Updated Date:
2014-02-12
Project Name:
JDK
Resolved Date:
2013-07-22
Component:
client-libs
OS:
windows
Sub-Component:
2d
CPU:
generic
Priority:
P1
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
6u71 (b01)

Related Reports
Backport:
Backport:
Backport:

Sub Tasks

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
                                     
2013-11-07
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??
                                     
2013-11-05
Migrated from 6u72.
                                     
2013-09-27
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.
                                     
2013-06-20
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.
                                     
2013-02-11
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.
                                     
2013-02-07



Hardware and Software, Engineered to Work Together