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 DocFlavor representing 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[0].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
DocFlavor
that the client can supply. The DocFlavor
's representation
class is a conduit for the DocPrintJob
to obtain a sequence of
characters or bytes from the client.