Spec-Zone .ru
спецификации, руководства, описания, API
CONTENTS | PREV | NEXT JavaTM Print Service API User Guide


How to Use DocFlavor

These steps illustrate the role of the DocFlavor in a typical application:

  1. A client determines the format of the print data and decides how to present the data to the printer. The client then creates or obtains a DocFlavorrepresenting the format:DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
  2. The client uses the DocFlavor to find printers that can understand the format specified by the DocFlavor and has the capabilities specified in the client's attribute set:PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, aset);
  3. From a print service, the client creates a print job, represented by a DocPrintJob object:DocPrintJob printJob = services[0].createPrintJob();
  4. The client creates a Doc representing the document to be printed:Doc doc = new InputStreamDoc("duke.gif", flavor);
  5. The client prints the document by calling the print method of the DocPrintJob object:printJob.print(doc, aset);When the client passes the Doc object to the print method, the DocPrintJob object obtains the print data from the Doc object and determines the doc flavor that the client can supply. The doc flavor's representation class is a conduit for the DocPrintJob to obtain a sequence of characters or bytes from the client.
The Printing and Streaming Documents chapter demonstrates a complete printing application.



CONTENTS | PREV | NEXT
Copyright © 2001 Sun Microsystems, Inc. All Rights Reserved.