• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

PrintService - How to access a media tray?

 
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
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!