I currently retrieve some printer information about the possible media trays with this code snippet:
Media med[] = (Media[])printService.getSupportedAttributeValues(Media.class, null, null);
if( med != null ) {
for (int k=0; k<med.length; k++) {
sb.append("Name : " + med[k].getClass() + " - Value : " + med[k].getValue() +
" - Name : " + med[k].getName()+"\n" );
}
}
Sadly, this just returns some tray numbers, which I find relatively useless:
Name : class javax.print.attribute.standard.MediaSizeName - Value : 40 - Name : media
Name : class javax.print.attribute.standard.MediaSizeName - Value : 41 - Name : media
Name : class javax.print.attribute.standard.MediaSizeName - Value : 42 - Name : media
... more ...
Name : class sun.print.Win32MediaTray - Value : 5 - Name : media
Name : class sun.print.Win32MediaTray - Value : 25 - Name : media
Name : class sun.print.Win32MediaTray - Value : 26 - Name : media
Name : class sun.print.Win32MediaTray - Value : 27 - Name : media
How can I retrieve useful names?
This will give you all printer properties, including tray names