title: How to get the raw printer tray ID
body: <p>I’m trying to find the printer tray ids of a particular printer. I have searched and found a lot of articles in Java using the <code>PrintService</code>, Media and <code>MediaTray</code>. Yet, this doesn’t provide a solution for my requirement.  I will get the following output if I run the below code.</p>
  
  <pre><code>String printName = "AL-M2010-3D8E02";
  AttributeSet aset = new HashAttributeSet();
  aset.add(new PrinterName(printName, null));
  PrintService[] services = PrintServiceLookup.lookupPrintServices(null, aset);
  for (int i = 0; i &lt; services.length; i++) {
      PrintService service = services[i];
      System.out.println(service);
      DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
      Object o = service.getSupportedAttributeValues(Media.class, flavor, null);
      if (o != null &amp;&amp; o.getClass().isArray()) {
          for (Media media : (Media[]) o) {
              if (media instanceof MediaTray) {
                  System.out.println(media + " ID: " + media.getValue() + "\t" + media.getClass().getName());
              }
          }
      }
  }
  </code></pre>
  
  <p>Win32 Printer : AL-M2010-3D8E02</p>
  
  <p>Form-Source ID: 5   sun.print.Win32MediaTray</p>
  
  <p>MP Tray ID: 6   sun.print.Win32MediaTray</p>
  
  <p>Lower Cassette 1 ID: 7  sun.print.Win32MediaTray</p>
  
  <p>Lower Cassette 2 ID: 8  sun.print.Win32MediaTray</p>
  
  <p>Lower Cassette 3 ID: 9  sun.print.Win32MediaTray</p>
  
  <p>Lower Cassette 4 ID: 10 sun.print.Win32MediaTray</p>
  
  <p>If I run the following .net code I would get the following outpt.</p>
  
  <pre><code>PrintDocument printDoc = new PrintDocument();
  printDoc.PrinterSettings.PrinterName = "AL-M2010-3D8E02";
  
  for (int i = 0; i &lt; printDoc.PrinterSettings.PaperSources.Count; i++)
  {
      trayDetails.AppendText(printDoc.PrinterSettings.PaperSources[i].SourceName + " " + printDoc.PrinterSettings.PaperSources[i].RawKind.ToString());
      trayDetails.AppendText(Environment.NewLine);
  }
  </code></pre>
  
  <p>Automatically Select 15</p>
  
  <p>MP Tray 261</p>
  
  <p>Lower Cassette 1 260</p>
  
  <p>Lower Cassette 2 259</p>
  
  <p>Lower Cassette 3 258</p>
  
  <p>Lower Cassette 4 257</p>
  
  <p>The above is what I want to achieve. I want to get the raw printer ID like 260, 259, 258 and so on through Java instead of getting 7,8,9 and 10. Is this possible in some way?</p>