Select tray / tray when printing with javax.print

I want to specify input cells when printing using Java. I found the MediaTray class that should match the input beans:

The following standard values are defined for input-trays (from ISO DPA and the Printer MIB): 'top': The top input tray in the printer. 'middle': The middle input tray in the printer. 'bottom': The bottom input tray in the printer. 'envelope': The envelope input tray in the printer. 'manual': The manual feed input tray in the printer. 'large-capacity': The large capacity input tray in the printer. 'main': The main input tray 'side': The side input tray 

Source: http://tools.ietf.org/html/rfc2911

The problem is that I get a number from the application that indicates the input bit. Can I just match the enum int values, or what is the general way to get the enum value with a number? Is even official support for tray numbers supported?

I could not find the attributes in the RFC that matched the output bins. Is there any way to do this?

And the most important question: a more or less reliable printer interface? Most of the flows that I found when people asked about trays eventually gave up because they couldn’t get it working.

Any impressions would be appreciated.

+4
source share
3 answers

These attributes are defined in javax.print.attribute.standard.MediaTray . See Also Standard Attributes: Media .

+2
source

If you want to use the equalizer number, and not common constants such as TOP, you will need to do additional encoding. There is no enumeration listing all the tray numbers for this printer, since during encoding it is not known how many trays will be known. You need to request the print service for all supported attribute values ​​for the typeout Media.class attribute. This will give you a list of different types. Print the results, the trays should be somewhere on this list. It is important to take the tray from this list, and not build it yourself, because it is associated with some code inside the code in the print structure. A.

Note : Printing api has some errors related to printing trays (especially on unix). To quickly solve them, vote for: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7107175 and / or http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7107138

+1
source

This is how to print to "Tray 1" (if it exists):

 PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); Media[] supportedMedia = (Media[]) prnJob.getPrintService().getSupportedAttributeValues(Media.class, null, null); for (Media m : supportedMedia) { if (m.toString().equals("Tray 1")) { aset.add(m); break; } } 
+1
source

All Articles