Using the Java Print Services APIs on the iSeries System

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

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 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:

    • If *IPDS is specified for this parameter, the AFP parameter value will be checked. If it's *YES, the JPS implementation checks if the Infoprint Server for iSeries product is installed. If so, the list of supported MIME types for this printer configuration includes PS, PCL, PDF, AFPDS and SCS. If Infoprint Server for iSeries is NOT installed, then the only supported MIME types are AFPDS and SCS.
    • If the AFP parameter value is *NO, then the only supported MIME type is SCS.
    • If the TYPE parameter isn't *IPDS, then the iSeries JPS checks for the TRANSFORM parameter value in the device configuration. If the value is *YES (host print transform is enabled), the JPS communicates with the printer (using the SNMP protocol) to determine printer data streams supported. For this scenario, the supported MIME types include SCS, AFPDS and these MIME types reported back by the printer device.
    • If the TRANSFORM parameter value is *NO, the JPS again communicates with the printer device to get data streams supported by the printer. In this case, the supported MIME types include the MIME types reported back by the printer device.
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.

Ken Dittrich is a senior software engineer with IBM. Ken can be reached at

comments powered by Disqus



2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters