|CONTENTS | PREV | NEXT||JavaTM Print Service API User Guide|
These steps illustrate the role of the DocFlavor in a typical application:
The Printing and Streaming Documents chapter demonstrates a complete printing application.
- 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;
- 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);
- From a print service, the client creates a print job, represented by a DocPrintJob object:DocPrintJob printJob = services.createPrintJob();
- The client creates a Doc representing the document to be printed:Doc doc = new InputStreamDoc("duke.gif", flavor);
- 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.