The release of JDK 1.4 introduced the Java* Print Service (JPS) APIs, which enable Java client and server applications to use the print services provided by implementations of the APIs. Using the APIs involves three steps - discover and select print services based on their capabilities, specify the format of the print data and submit print jobs to the selected services that support the document type to be printed. The iSeries* implementation of the JPS APIs was introduced with OS/400* V5R2 and packaged in Option 3 of the OS/400 product 5722-SS1. With the iSeries JPS APIs, applications can locate and select physical printers configured on the iSeries system, and direct print jobs to the selected printer(s). While the IBM* Toolbox for iSeries provides a set of interfaces specific to i5/OS* to use the iSeries print services (resources), the iSeries JPS APIs provide a platform-independent print interface. This article provides information on how to use the iSeries implementation of the JPS interfaces and assumes that the reader is familiar with the JPS interfaces. Locating a Printer The lookupPrintService() method accepts two object parameters, an instance of a DocFlavor and an instance of an AttributeSet object that are used to locate a print service that can handle a print request specified by these two parameters. DocFlavor is an object that defines the type (format) of data (MIME type) that will be printed by the selected printService and also specifies how the document is delivered to the printer (via a name of a representation class). The iSeries print services support MIME types AFPDS, SCS, PCL, Postscript and PDF. To determine which MIME type(s) are supported by each print service (configured printer on the iSeries system), the iSeries JPS implementation initially interrogates the PUBLISHINF parameter values of the printer-device configuration. If values are specified for this parameter, then this list of values will be used to define the list of supported MIME types. If the PUBLISHINF parameter has no values specified in the printer-device configuration, then the TYPE parameter of the printer configuration is interrogated:
When a Java application wants to send a document to a selected iSeries printer, it must first use one of three static methods in the PrintServiceLookup class to locate and select the printer. The method lookupDefaultPrintService() finds the default- configured printer on the iSeries system, which is specified by the i5/OS system value QPRTDEV. If this value isn't specified, an instance of a print service for the first printer in a list of configured printers is returned. To get a list of all configured printers on the iSeries system or a list of printers with specific capabilities, use the static methods lookupPrintService() or lookupMultiDocPrintServices(). All three static methods return a reference to a printService object that represents a list of print services on the iSeries system.
The JPS APIs are simple to use and provide a standard method of accessing the print resources of an iSeries system from a Java client or server application, enhancing application portability.
Browse products and services for Administrator.