|
|||||||||
| Home >> All >> javax >> print >> [ attribute overview ] | PREV PACKAGE NEXT PACKAGE | ||||||||
Package javax.print.attribute
Provides the basic interfaces and classes of the Java Print Service API.
See:
Description
| Interface Summary | |
| Attribute | Base interface of every printing attribute of the Java Print Service API. |
| AttributeSet | AttributeSet is the top-level interface for sets of printing
attributes in the Java Print Service API. |
| DocAttribute | Marker interface for all attribute classes describing attributes of a javax.print.Doc object. |
| DocAttributeSet | DocAttributeSet specifies an attribute set which only
allows printing attributes of type
DocAttribute. |
| PrintJobAttribute | Marker interface for all attribute classes describing attributes or the status of a (javax.print.DocPrintJob object. |
| PrintJobAttributeSet | PrintJobAttributeSet specifies an attribute set which only
allows printing attributes of type
PrintJobAttribute. |
| PrintRequestAttribute | Marker interface for all attribute classes which specify a requested attribute of javax.print.DocPrintJob object. |
| PrintRequestAttributeSet | PrintRequestAttributeSet specifies an attribute set which only
allows printing attributes of type
PrintRequestAttribute. |
| PrintServiceAttribute | Marker interface for all attribute classes describing parameters or the status of a javax.print.PrintService. |
| PrintServiceAttributeSet | PrintServiceAttributeSet specifies an attribute set which only
allows printing attributes of type
PrintServiceAttribute. |
| SupportedValuesAttribute | Marker interface for all attribute classes specifying the supported/allowed values for another printing attribute class. |
| Class Summary | |
| AttributeSetUtilities | AttributeSetUtilities provides static methods for working
with AttributeSets. |
| AttributeSetUtilities.SynchronizedAttributeSet | |
| AttributeSetUtilities.SynchronizedDocAttributeSet | |
| AttributeSetUtilities.SynchronizedPrintJobAttributeSet | |
| AttributeSetUtilities.SynchronizedPrintRequestAttributeSet | |
| AttributeSetUtilities.SynchronizedPrintServiceAttributeSet | |
| AttributeSetUtilities.UnmodifiableAttributeSet | |
| AttributeSetUtilities.UnmodifiableDocAttributeSet | |
| AttributeSetUtilities.UnmodifiablePrintJobAttributeSet | |
| AttributeSetUtilities.UnmodifiablePrintRequestAttributeSet | |
| AttributeSetUtilities.UnmodifiablePrintServiceAttributeSet | |
| DateTimeSyntax | DateTimeSyntax is the abstract base class of all attribute
classes having a date and a time as value. |
| EnumSyntax | EnumSyntax is the abstract base class of all enumeration
classes in the Java Print Service API. |
| HashAttributeSet | HashAttributeSet provides an implementation of
AttributeSet. |
| HashDocAttributeSet | HashDocAttributeSet provides an implementation of
DocAttributeSet. |
| HashPrintJobAttributeSet | HashPrintJobAttributeSet provides an implementation of
PrintJobAttributeSet. |
| HashPrintRequestAttributeSet | HashPrintRequestAttributeSet provides an implementation of
PrintRequestAttributeSet. |
| HashPrintServiceAttributeSet | HashPrintServiceAttributeSet provides an implementation of
PrintServiceAttributeSet. |
| IntegerSyntax | IntegerSyntax is the abstract base class of all attribute
classes having an integer as value. |
| ResolutionSyntax | ResolutionSyntax is the abstract base class of all attribute
classes which provide a resolution as value (e.g. |
| SetOfIntegerSyntax | SetOfIntegerSyntax is the abstract base class of all attribute
classes which provide a set of non-negative integers as value (e.g. |
| Size2DSyntax | Size2DSyntax is the abstract base class of all attribute
classes which provide a two dimensional size as value (e.g. |
| TextSyntax | TextSyntax is the abstract base class of all attribute
classes which provide a string as value (e.g. |
| URISyntax | URISyntax is the abstract base class of all attribute
classes having an Uniform Resource Identifier URI as value. |
| Exception Summary | |
| UnmodifiableSetException | Exception which is thrown if an operation on an unmodifiable set is invoked. |
Package javax.print.attribute Description
Provides the basic interfaces and classes of the Java Print Service API.
The Java Print Service API enables programmers to:
- Discover print services for printing to printer devices and to output streams. The discovery process can be constrained to return only print services supporting specific document formats or printing attributes.
- Print client-formatted print data like Postscript, PDF or various image formats and service-formatted print data from Java.
- Submit, cancel and monitor single and multi document print jobs.
- Provide users a graphical print service browser with printing attribute selection.
Print Service Discovery
Print service types in the JPS API:- PrintService:
The base interface describing a print service capable of printing a supplied document for a given document format to the printer device it is representing. - MultiDocPrintService:
Extends the PrintService interface and provides a print service which is capable of printing multiple documents as one print job to its printer device. - StreamPrintService:
Extends the PrintService interface and provides a print service which is capable of printing into a supplied output stream instead of to a physical printer device.
PrintService, MultiDocPrintService
Discovery is done by the use of the static methods in the PrintServiceLookup class. The discovery process can be constrained by supplying the document formats and printing attributes that need to be supported by the returned print service. Furthermore the lookupDefaultPrintService() method enables to lookup the default print service of the platforms printing system.
StreamPrintService
StreamPrintService provides the same functionality as a print service for output to a suppliedOutputStream. Available stream print services are
discovered via the static methods in the
StreamPrintServiceFactory factory. The query can be constrained by supplying
the the requested document format support and the needed output format.
Document formats
The format of the printing documents are specified by the DocFlavor class in the JPS API. It provides the description of the format in which the print data will be supplied in a print job to the print service and consists of two parts:- The MIME type (Multipurpose Internet Mail Extensions types as described in RFC 2045/2046) specifying the media format of the print data.
- The representation class name which is the fully qualified name of the class providing the print data to the print job. For example if the print data is supplied as a byte array the representation class name will be "[B" or for an input stream "java.io.InputStream".
Printing attributes
Print services as well as print jobs report their state and capabilities by the way of supplying printing attributes. Also the behaviour of print jobs (like how many copies should be printed) is controlled via printing attributes. For these requirements the JPS API defines different roles of attributes and common syntax classes in the packagejavax.print.attribute. The actual available printing attributes
are implemented in the javax.print.attribute.standard package.
- Print service attributes:
These printing attributes of role PrintServiceAttribute report the status and other informations of a PrintService. Example for informations available in the print services attributes are the attributePagesPerMinuteproviding the number of pages a printer can print per minute. Status attributes like thePrinterStateattribute gives the current state (e.g. printer currently processes or is idle) of the printer. - Print job attributes:
Print job attributes of role PrintJobAttribute inform about the status of given print job. For example theNumberOfInterveningJobsattribute provides the number of jobs ahead in the print service queue before this job. Status attributes like theJobStateattribute gives the current state of the print job (like pending, processing or canceled). - Print request attributes:
The attributes of role PrintRequestAttribute specify the behaviour of a complete print job. The print request attributes apply to all documents in a print job, whereas the doc attributes only apply to the specific document in a print job. Most of the print request attributes are also doc attributes and therefore implementing both attribute role interfaces. - Doc attributes:
As described above the PrintJobAttribute attributes are specific to a single document in the print job.
Example of using the API
import java.io.*;
import javax.print.*; import javax.print.attribute.*; import javax.print.attribute.standard.*; import javax.print.event.*;
public class Beispiel { public static void main(String[] args) { // Using the predefined doc flavor for postscript mimetype DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
// Looking for printservice supporting this doc flavor PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, null);
// Just take the first PrintService service = services[0]; System.out.println("Name :" + service.getName());
try { // Create a print job DocPrintJob job = service.createPrintJob();
// We want to print a file so we construct an inputstream // on the file to supply the print data as given in the doc flavor File file = new File("File.ps"); InputStream stream = new FileInputStream(file);
// Build a attribute set with the wanted printing attributes HashPrintRequestAttributeSet attr = new HashPrintRequestAttributeSet(); attr.add(new Copies(2)); // two copies attr.add(new PageRanges(2, 7)); // only the 2-7 pages
// Construct a doc object with the provided class SimpleDoc SimpleDoc doc = new SimpleDoc(stream, flavor, null);
// register us as the print - use the adapter class // and override the interesing failure condition job.addPrintJobListener(new PrintJobAdapter() { public void printJobFailed(PrintJobEvent arg0) { System.out.println("The PrintJob failed."); } });
// start the printing process job.print(doc, attr);
// lets assume we want to cancel it if (job instanceof CancelablePrintJob) { CancelablePrintJob cancelJob = (CancelablePrintJob) job; cancelJob.cancel(); }
} catch (PrintException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } } }
Since: 1.4
|
|||||||||
| Home >> All >> javax >> print >> [ attribute overview ] | PREV PACKAGE NEXT PACKAGE | ||||||||