| package javax.print
|
Java SE 6 |
| Details
Provides the principal classes and interfaces for the
JavaTM Print Service API.
The Java Print Service API enables client and server applications to:
Print Service Discovery
An application invokes the static methods of the abstract class
The JDK includes Attribute DefinitionsThejavax.print.attribute and javax.print.attribute.standard
packages define print attributes, which describe the capabilities of a print
service, specify the requirements of a print job, and track the progress of
a print job.
The Document Type SpecificationTheDocFlavor class represents the print data
format, such as JPEG or PostScript. A DocFlavor object
consists of a MIME type, which describes the format, and a document
representation class name that indicates how the document is delivered
to the printer or output stream. An application uses the
DocFlavor and an attribute set to find printers that can
print the document type specified by the DocFlavor and have
the capabilities specified by the attribute set.
Using the APIA typical application using the Java Print Service API performs these steps to process a print request:
FileInputStream psStream; try { psStream = new FileInputStream("file.ps"); } catch (FileNotFoundException ffne) { } if (psStream == null) { return; } DocFlavor psInFormat = DocFlavor.INPUT_STREAM.POSTSCRIPT; Doc myDoc = new SimpleDoc(psStream, psInFormat, null); PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(new Copies(5)); aset.add(MediaSize.A4); aset.add(Sides.DUPLEX); PrintService[] services = PrintServiceLookup.lookupPrintServices(psInFormat, aset); if (services.length > 0) { DocPrintJob job = services[0].createPrintJob(); try { job.print(myDoc, aset); } catch (PrintException pe) {} } Please note: In the javax.print APIs, a null reference parameter to methods is incorrect unless explicitly documented on the method as having a meaningful interpretation. Usage to the contrary is incorrect coding and may result in a run time exception either immediately or at some later time. IllegalArgumentException and NullPointerException are examples of typical and acceptable run time exceptions for such cases.
|
| About DocWeb · Bundles · Export · Export All | Top 10 · Statistics · Login |
| About Sun · Contact · Privacy · Terms of Use · Trademarks | Java SE 6 · Copyright © 1994-2009 Sun Microsystems, Inc.All rights reserved. Use is subject to license terms |
![]() |
![]() |
|