media sizes with width > height are not supported by the java printing api

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P3
    • tbd
    • Affects Version/s: 7u21, 8, 9
    • Component/s: client-libs
    • 2d
    • windows_7

      FULL PRODUCT VERSION :
      java version " 1.7.0_21 "
      Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
      Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Label Printer TD-4000 Brother

      A DESCRIPTION OF THE PROBLEM :
      The function PrintService.getDefaultAttributeValue(Media.class) returns a wrong media, if a media is configured (under windows printer settings for the printer) with width of media greater than its height. Furthermore the list with supported media as returned by the method PrintService.getSupportedAttributeValues(Media.class, null, null) is not complete, it does not contain medias with width > heigth, but only a small subset of the supported media by the printer. This problem occurs with the Label Printer TD-4000 from Brother, but i think it occurs with other printers too, which have media dimensions with width > height.
      The bug lies probably in the class Win32PrintService where the class MediaSize is instantiated. The constructor of MediaSize forbids dimensions with width > height.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Install printer driver for the Label Printer TD-4000 from Brother
      2. set the printer TD-4000 as the default printer in windows
      3. in printer settings for the printer TD-4000 select the paper size " RD 76mm x 26mm " if it is not already selected.
      4. Run the provided class MediaTest

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      default media:
      RD 76mm x 26mm

      supported medias:
      RD 76mm x 26mm
      RD 51mm x 26mm
      RD 102mm x 50mm
      RD 102mm x 152mm
      RD 58mm
      RD 76mm
      RD 90mm
      RD 102mm
      32mm x 25mm
      57mm x 32mm
      57mm x 51mm
      57mm x 64mm
      76mm x 26mm
      76mm x 76mm
      102mm x 25mm
      102mm x 64mm
      102mm x 76mm
      102mm x 102mm
      102mm x 127mm
      ACTUAL -
      default media:
      RD 102mm x 152mm

      supported medias:
      RD 102mm x 152mm
      57mm x 64mm
      76mm x 76mm
      102mm x 102mm
      102mm x 127mm

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.print.PrintService;
      import javax.print.PrintServiceLookup;
      import javax.print.attribute.standard.Media;

      public class MediaTest {

          public static void main(String[] args) {
              final PrintService service = PrintServiceLookup.lookupDefaultPrintService();
              
              Media media = (Media) service.getDefaultAttributeValue(Media.class);
              
              Media [] medias = (Media[]) service.getSupportedAttributeValues(Media.class, null, null);
              
              System.out.println( " default media:
       " + media);
              
              System.out.println( "
      supported medias: " );
              for(Media med : medias) {
                  System.out.println(med);
              }
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Quick fix is to override the class javax.print.attribute.standard.MediaSize with a modified version of it, where the constraint that the widht must be less or equal than height is uncommented. The constraint is checked in the constructor of the class MediaSize, if it is not held, a IllegalArgumenException is thrown.
      (The override can be done via the bootstrap class path option -Xbootclasspath/p, but it violates the license)

            Assignee:
            Philip Race
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: