Category Archives: Attributes

Getting the attributes from the PrintService

Introduction

The Java Print Service API allows  printing on all Java platforms including those requiring a small footprint, such as a Java ME profile, but also supports the java.awt.print.PrinterJob API. The Java Print Service API includes an extensible print attribute set based on the standard attributes specified in the Internet Printing Protocol (IPP) 1.1 from the IETF. With the attributes, client and server applications can discover and select printers that have the capabilities specified by the attributes. In addition to the included StreamPrintService, which allows applications to transcode data to different formats, third parties can dynamically install their own print services through the Service Provider Interface. The example below shows how these attributes can be obtained.

Attribute[] attrs = service.getAttributes().toArray();
for (int j=0; j<attrs.length; j++) {
    String attrName = attrs[j].getName();

    // Retrieve the string version of the
    // attribute value
    String attrValue = attrs[j].toString();
    process(service, attrName, attrValue);
}