Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

PrintService - How to access a media tray?  RSS feed

 
Nick Brosky
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I tried to access the second Media Tray on a Lexmark T420, but it allways prints from the first. So I checked what kind of attributes are available with the following code:

MediaTray tray = MediaTray.MAIN;
myFormat = DocFlavor.BYTE_ARRAY.POSTSCRIPT;
supported = (Media [])printService.getSupportedAttributeValues(tray.getCategory(), myFormat, null);
if (supported != null){
for (int i = 0; i < supported.length; i++){
LOG.info("Available Media for BYTE_ARRAY.POSTSCRIPT: " + supported[i].getName()
+ " " + supported[i].getValue()
+ " " + supported[i]
+ " " + supported[i].getClass());
}
}
And I got:

Available Media for BYTE_ARRAY.POSTSCRIPT: media 40 na-letter class javax.print.attribute.standard.MediaSizeName
Available Media for BYTE_ARRAY.POSTSCRIPT: media 44 tabloid class javax.print.attribute.standard.MediaSizeName
Available Media for BYTE_ARRAY.POSTSCRIPT: media 43 ledger class javax.print.attribute.standard.MediaSizeName
Available Media for BYTE_ARRAY.POSTSCRIPT: media 41 na-legal class javax.print.attribute.standard.MediaSizeName
Available Media for BYTE_ARRAY.POSTSCRIPT: media 42 executive class javax.print.attribute.standard.MediaSizeName
Available Media for BYTE_ARRAY.POSTSCRIPT: media 3 iso-a3 class javax.print.attribute.standard.MediaSizeName
Available Media for BYTE_ARRAY.POSTSCRIPT: media 4 iso-a4 class javax.print.attribute.standard.MediaSizeName
Available Media for BYTE_ARRAY.POSTSCRIPT: media 5 iso-a5 class javax.print.attribute.standard.MediaSizeName
Available Media for BYTE_ARRAY.POSTSCRIPT: media 15 iso-b4 class javax.print.attribute.standard.MediaSizeName
Available Media for BYTE_ARRAY.POSTSCRIPT: media 16 iso-b5 class javax.print.attribute.standard.MediaSizeName

So I tried each:

MediaSizeName[] msn = {MediaSizeName.NA_LETTER, MediaSizeName.TABLOID, MediaSizeName.LEDGER,
MediaSizeName.NA_LEGAL, MediaSizeName.EXECUTIVE, MediaSizeName.ISO_A3,
MediaSizeName.ISO_A4, MediaSizeName.ISO_A5, MediaSizeName.ISO_B4,
MediaSizeName.ISO_B5};
for(int i = 0; i < msn.length; i++){
printAttributes.clear();
printAttributes.add(msn[i]);
job = printService.createPrintJob();

job.print(printDoc, printAttributes);
}

But again I just got one print from the first tray.
I checked the printer with JEdit, where I chose the second tray and it worked!

Has anybody an idea how to do it in Java? Is it possible at all?

Regards,
Nick
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!