Java Printservice

Introduction

java printservice It is the Java(tm) Print Service (Java Printservice) is a brand-new Java Print API which is specifically designed to allow printing across every Java platforms, which includes platforms with a limited footprint but it also works with the Java(tm) 2. Print API.

The unified Java Print API includes extensible print attributes based upon the common attributes defined within the Internet Printing Protocol (IPP) 1.1 from the IETF Specification, RFC 2911. By together the attributes, both client and server applications are able to discover and select printers that meet the capabilities described by attributes. In addition to the StreamPrintService that lets applications transcode print data into various formats, third parties can install dynamically their own printing services via this Service Provider interface.

History of Printing on the Java Printservice

Basic printing capabilities on printing on the java printservice was initially added with the Java Development Kit Version 1.1 from 1997. Its JDK 1.1 printing API gave developers an elementary framework to print the user interface material of client software. JDK 1.1 printing is also known as”the AWT Printer API built on the basis of java.awt.PrintJob class that wraps the printing request. The PrintJob class is an instance of Graphics that implements rendering of the page.

In 1998, JDK 1.2 advanced printing capabilities on the Java platform by implementing the java.awt.print package that allows applications to print Java 2D graphics that includes 2D images, text and images.

In JDK version 1.3 The JobAttributes as well as the PageAttributes classes were added to AWT printing, so that clients could define the print properties of a job as well as the attributes that are associated with the page.

The two APIs mostly provide page imaging that is the formatting and rendering of pages and is a key part of the printing subsystem. While a user can select an choice to print from a print dialog, and indicate printing characteristics with PageAttributes or JobAttributes neither of the AWT or Java 2D printing APIs support printing devices based on their capabilities. This is an more key element to any printer subsystem. For more information on the printing history using the Java platform, refer to printing using Java Platform. Java Platform.

What the Java Printservice API Offers

Java Print Service API Java Print Service API unifies and extends printing capabilities on the Java platform by taking care of many of the printing requirements of both server and client applications that aren’t met by the existing Java printer API.

In addition to enabling the current Java 2D printing features, Java Print Service also supports the current 2D printing features. Java Print Service offers many enhancements, such as:

Client and server applications are able to identify and select printers according to their capabilities. They also determine the specifications of printing jobs. Therefore, the JPS offers the missing component in a printing subsystem automatic printer discovery.

Implementations of common IPP attributes are integrated into JPS API. JPS API as first-class objects.

The attributes of applications can be extended by the API that are included in JPS API. JPS API.

Third party providers can connect their own printing services via Service Provider Interface. Service Provider Interface.

Java Printservice Architecture

The Java Print Service API consists of four packages: javax.print, javax.print.attribute, javax.print.attribute.standard, and javax.print.event.

The javax.print Package

The javax.print package is the primary package that is part of the API. It has interfaces and classes that allow you to:

Discover Print Services

Indicate the format of the print data

Print jobs with the print service

Send the print information to a printer or stream

Discover Print Services

A program invokes printservicelookup’s static method, to identify print service providers with the capacity to fulfill the request for printing from the application. For instance, if one wants for printing a double-sided print it is first necessary for the application to locate printers with double-sided printing capabilities.

The application of the PrintService interface represents a genuine printer that can be found through an implementation of PrintServiceLookup. PrintService can be accessed via the PrintService can be used to discover its capabilities by calling one of the various ways to return the attributes of the PrintService that are supported by it. It is the Searching for services part in chapter chapter on Printing as well as streaming documents chapter explains with java printservice as well as java printservice Lookup.

java printservice is a platform for java printservice includes java printservice Lookup functions that allow you to find the common printers on the platform. To locate different types of printers like IPP printers, or JINI printers A print-service provider is able to develop implementations for PrintServiceLookup. Print-service providers can automatically install these PrintServiceLookup implementations with an SPI JAR specifications for files.

Instead of sending data to a printer the application could also print the data onto streams of output together the StreamPrintService. This permits the application to transform the data into different formats. To obtain a StreamPrintService, an application uses the lookup methods of the StreamPrintServiceFactory abstract class. It is akin to the PrintServiceLookup class, in that it can also find printing services.

The chapter Printing and Streaming Documents describes using Stream java printservice Factory and StreamPrintService. A StreamPrintService can be used to also send 2D images into streams of output. Read the Printing section and streaming 2D Graphics to find more information.

Specify the Print Data Format

The DocFlavor class is the format for printing data, like JPEG and PostScript. A DocFlavor object is composed of an MIME type that defines the format and an identifier for the representation class like java.io.InputStream which specifies how it will be sent into the application. To make things easier for users, the java printservice API also comes with pre-defined DocFlavor objects that represent common formats for data. The document types that are specified in the chapter explains the specific ways to utilize DocFlavor objects.

java printservice
java printservice

Create Print Jobs

When a print service that is suitable is identified, an application generates a print task using it. Print jobs are represented in an object called the DocPrintJob class that is responsible for the actual printing method. Before calling print, the application creates a Doc object to encapsulate the print data and the print request attributes, which are defined in the javax.print.

attribute and javax.print.attribute.standard packages. In the chapter printing and streaming documents explores with Doc as well as DocPrintJob. A program that is with Java Print Service to print 2D graphics. Java Print Service to print 2D Graphics can use either the PrinterJob class or the DocPrintJob class. In the chapter printing and streaming 2D graphics explores together PrintJob and the Java Print Service to print 2D graphics.

The Attribute Packages

The java printservice and java printservice standard packages define print attributes, which describe a capability of a print service, a charactaristic of a document, an instruction for processing a document or an entire print job, or the state of a print job or printer.

The java printservice attribute package describes the types of attributes and how they can be collected into sets. The Attribute interface is the most powerful interface to all attribute. The java printservice attribute package includes classes and interfaces defining the five different kinds of attributes, each of which describes the capabilities of one piece of the printing process. For example, the Print Request Attribute interface defines attributes that clients use to describe the characteristics of a print job, which might include the number of copies to print.

The javax.print.attribute.standard package enumerates all of the standard attributes supported by the API, most of which are implementations of attributes specified in the IPP specification. The Attributes chapter provides an overview of more about the attributes API in greater in depth.

The java printservice event Package

The javax.print.event package includes classes that permit applications to sign up for events related to printing jobs and printing services. Check out the Registering for Events section for more details on how to register for print-related events.

How Applications Use the java printservice

The typical program with Java Print Service API Java Print Service API performs these steps to handle a print request

Find the appropriate DocFlavor. It is an underlying class that defines the format for the printed data.

Create and fill in an AttributeSet that encapsulates an array of attributes that define the capabilities of a print service that you want to use like the capability for printing 5 copies of a document, stapled and double-sided.

Find a print service which can manage the print request in accordance with the specifications set by DocFlavor along with the associated attribute.

Print a job using java printservice.

Print the print job together the printing method.

The application handles these steps differently based on what it wants to print. The application may send print information to a printer, or out a stream. The print information can be an image or text document of images or text, or a Jav, an object that contains 2D graphics. If the print data consists of 2D graphics, the print job can be represented with either the form of a DocPrintJob or an PrinterJob. If the print information is a text file, the DocPrintJob should be used.

The combination of printing methods along with print formats provide an array of six printing techniques:

Print documents to the printer with DocPrintJob, a DocPrintJob and a implementation of PrintService

You can stream a document to an output stream together the DocPrintJob and StreamPrintService. DocPrintJob and the PrintService called StreamPrint

Print 2D images to an printer together the DocPrintJob DocPrintJob and the implementation of PrintService

Send 2D images to an output stream together an DocPrintJob and a streamprint service

Print 2D graphics to a PrintService using java.awt.print.PrinterJob

Stream 2D graphics to a StreamPrintService using java.awt.print.PrinterJob

 

Leave a Comment