Printing documents on IBM I using the Java print Service API

Source: Internet
Author: User
Tags abstract event listener

Java Printer Service (JPS) Introduction

JPS (Java Print Service) is a set of Java class libraries for Java programs that provide print services on IBM i. It supports many different formats of document printing, such as: PDF,PS,PCL. You can use some of the classes it provides to write applications about printing. It is usually divided into three steps: first select the appropriate print service, then specify the format of the printed data, and finally submit the print job to the print service for printing.

On the IBM I server, JPS's jar bundle is/qibm/proddata/os400/java400/ext/ibmjps.jar, which provides a series of APIs to support the printing of documents above IBM I. such as class Iseriesprintservice,iseriesprintjob,iseriesrasterprinterjob and subclasses related to print services and jobs, and class iseriesstreamprintjob related to streaming printing, Genericstreamprintservice and its subclasses, and so on. These classes define the methods and properties for using the print services provided by IBM I.

This article mainly introduces IBM I above the JPS API. The content will include:

How the JPS API works

Introduction to JPS API structure

How the application invokes the JPS API to implement IBM I printing, and describes this feature through an example program

How the JPS API works

On the IBM i server, a print service represents a printing device created with a command (CRTDEVPRT). When an application prints a job using the print service, the Print Service places the corresponding spool file in the output queue that is the same name as the print device (same as the name specified in the printer name attribute). After the document enters the print device, it uses STRPRTWTR to start a print job for printing.

Introduction to JPS API structure

The IBM I JPS API provides specific classes such as Iseriesprintservice, Iseriesprintjob, and abstract classes Iseriesrasterprin terjob and their subclasses iseriespclprinterjob, ISeri Espdfprinterjob,iseriespsprinterjob to support printing of documents. Iseriesstreamprintjob and abstract class Genericstreamprintservice and their subclass Pclstreamprintservice,pdfstreamprintservice are also provided. Psstreamprintservice to support streaming print services to the data stream. Next, we will focus on the related properties and methods of these classes.

Specific class Iseriesprintservice

This class implements the interface Javax.print.PrintService provided in the JDK and provides a print service for a print job. It realizes the method of Printservice createprintjob,getattributes and so on. Inside the Createprintjob method, it creates a Iseriesprintjob object, and eventually it calls the Print method to complete the printing function. GetAttributes returns a description of all print properties for this print service.

Main Method Introduction:

Docprintjob Createprintjob ()

Create a print job

Printserviceattributesset getattributes ()

Returns a description of all print properties for this print service

String GetName ()

Returns the name of the print device that corresponds to this print service

Docflavor[] Getsupporteddocflavors ()

Returns the print data format supported by this print service

Specific class Iseriesprintjob

The class inheritance structure diagram associated with the class is shown below. (Iseriesstreamprintjob in paragraph)

This class implements the interface Docprintjob and Cancelableprintjob provided in the JDK, which represents a print job above IBM i. An instance of the class is created in the Iseriesprintservice Createprintjob method. Its print method eventually calls a subclass of Iseriesrasterprinterjob to complete the print job for the corresponding data format.

Main Method Introduction:

void Print (Doc doc, printrequestattributeset attributes)

Prints a document based on the specified job properties

void Cancel ()

Canceling a print job

void Addprintjoblistener (Printjoblistener listener)

To add an event listener to a print job

Printjobattributeset getattributes ()

Get print properties for print jobs

Specific class Iseriesstreamprintjob

This class implements the interface docprintjob provided in the JDK, which represents a stream print job above IBM i. A streaming print job allows an application to convert data into different formats. For example, a PDF document is exported in PCL format to a spool file. An instance of the class is created in the Genericstreamprintservice Createprintjob method and invoked by one of its three subclasses. Its print method eventually calls a subclass of Iseriesrasterprinterjob to complete the print job for the corresponding data format.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.