Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7530849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:01:29+00:00 2026-05-30T05:01:29+00:00

I currently retrieve some printer information about the possible media trays with this code

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:01:31+00:00Added an answer on May 30, 2026 at 5:01 am

    This will give you all printer properties, including tray names

    String printName = "HP Officejet Pro 8500 A910 (Network)";
    AttributeSet aset = new HashAttributeSet();
    aset.add(new PrinterName(printName, null));
    PrintService[] services = PrintServiceLookup.lookupPrintServices(null, aset);
    for (int i = 0; i < 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 && o.getClass().isArray()) {
        for (Media media : (Media[]) o) {
          System.out.println(media + " ID: " + media.getValue() + "\t" + media.getClass().getName());
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a code in VBA to retrieve prices for some financial models.
Currently I use the following code to retrieve the IP address of the local
How can I retrieve the current working directory of cmd.exe? This seems possible. For
In several recent answers I see this code given as the way to retrieve
I currently have some code which returns a sites header content back: #!/usr/bin/perl use
Dear, I currently face some problem to retrieve the value of a property setted
I read some useful posts here on SO about previous maven questions, I'm currently
I am currently using JQuery Ajax to retrieve and display some data as follows.
We are currently migrating our VB6 application to Net. The VB6 code uses some
Currently using the HTTPServletRequest class and specifically the .getQueryString method to retrieve an inputted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.