The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.print.attribute  [4 examples]

e707. Determining Print Job Capabilities Supported by a Print Service

The capabilities of a print job are called print job attributes. Examples of print job attributes include - Copies, OrientationRequested, and Destination. This example demonstrates how to retrieve the supported print job attributes of a print service.
    // Get all print job attributes of a print service
    Class[] cats = service.getSupportedAttributeCategories();
    for (int j=0; j<cats.length; j++) {
        Attribute attr = (Attribute)service.getDefaultAttributeValue(cats[j]);
    
        if (attr != null) {
            // Get attribute name and values
            String attrName = attr.getName();
            String attrValue = attr.toString();
    
            Object o = service.getSupportedAttributeValues(attr.getCategory(), null, null);
            if (o.getClass().isArray()) {
                for (int k=0; k<Array.getLength(o); k++) {
                    Object o2 = Array.get(o, k);
                }
            }
        }
    }

 Related Examples
e706. Determining the Capabilities of a Print Service
e708. Getting the Default Value of a Print Job Capability
e709. Getting the Possible Values for a Print Job Capability


© 2002 Addison-Wesley.