Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7052259

Unable to select media trays for printers on Unix platforms

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 6
    • client-libs
    • 2d
    • generic
    • linux

      SYNOPSIS
      --------
      Unable to select media trays for printers on Unix platforms

      FULL JDK VERSION
      ----------------
      Java 6 (tested with 6u25)
      JDK7 (tested with b143)

      OPERATING SYSTEM
      ----------------
      Unix (tested with Linux)

      SYNOPSIS
      --------
      Unable to select media trays for printers on Unix platforms

      PROBLEM DESCRIPTION
      -------------------
      It seems to be impossible to select media trays for printers on Unix platforms. We have tested with the same printer on Windows and Linux - on Windows the media trays are available, on Linux they are not. We also tested with a native print dialog on Linux, with the same printer, and the media trays are available for selection there. So this seems to be a JDK issue.

      REPRODUCTION INSTRUCTIONS
      -------------------------
      Compile and run the attached test

      Expected Behavior:
      This is the output observed on Windows

      ------------------------------------------------------------------------
      ...
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 40, Media: na-letter
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 44, Media: tabloid
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 41, Media: na-legal
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 45, Media: invoice
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 42, Media: executive
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 3, Media: iso-a3
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 4, Media: iso-a4
      ...

      Class Name: class sun.print.Win32MediaTray, Media Value: 5, Media: Form-Source
      Class Name: class sun.print.Win32MediaTray, Media Value: 35, Media: Auto Select
      Class Name: class sun.print.Win32MediaTray, Media Value: 36, Media: Tray 1
      Class Name: class sun.print.Win32MediaTray, Media Value: 37, Media: Tray 2
      ...
      ------------------------------------------------------------------------

      Observed behaviour:
      This is the output observed on Linux, for the same printer

      ------------------------------------------------------------------------
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 40, Media: na-letter
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 44, Media: tabloid
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 43, Media: ledger
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 41, Media: na-legal
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 42, Media: executive
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 3, Media: iso-a3
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 4, Media: iso-a4
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 5, Media: iso-a5
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 15, Media: iso-b4
      Class Name: class javax.print.attribute.standard.MediaSizeName, Media Value: 16, Media: iso-b5
      ------------------------------------------------------------------------

      Note that there are no media trays listed, unlike the Windows output.

      => we are not able to select a specific tray for printing on Linux/Unix

      TESTCASE
      --------
      import javax.print.PrintService;
      import javax.print.PrintServiceLookup;
      import javax.print.attribute.standard.Media;

      public class PrintTest {

          public void listPrinters() {
              PrintService service = null;
              PrintService[] services = PrintServiceLookup.lookupPrintServices(null,null);

              System.out.println("List of printers");

              // Determine the Print service
              for (int i=0; i<services.length; i++) {
                  String printName = "";
                  String selString = "";

                  printName = services[i].getName();
                  System.out.println("******************************************************");
                  System.out.println("Printer Name : "+printName);
                  System.out.println("Printer Implementation Class : "+services[i].getClass());
                  System.out.println("******************************************************");
                  printerSupportedAtrributes(services[i]);
              }


          }

          public void printerSupportedAtrributes(PrintService printer) {
              // Determine the Print Tray
              if (printer != null) {
                  Media med[] = (Media[])printer.getSupportedAttributeValues(Media.class, null, null);
                  for (int k=0; k<med.length; k++) {
                      String a = "Class Name: " + med[k].getClass() + ", Media Value: " + med[k].getValue() + ", Media: " + med[k].toString() +"";
                      System.out.println(a);
                  }
              }
              System.out.println("\n\n");
          }

          public static void main(String[] args) {
              PrintTest p = new PrintTest();
              p.listPrinters();
          }
      }

            jgodinez Jennifer Godinez (Inactive)
            dkorbel David Korbel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: