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


Creating a Doc

To create a Doc you must provide an implementation of the Doc interface. The Java Print Service API provides a convenient implementation of Doc called SimpleDoc. An application is not required to use the SimpleDoc implementation, but to ensure compliance with Doc, any Doc implementation must observe the same required semantics that SimpleDoc implements, which are:

Before creating a Doc, you need to load your document from the file. The representation class of the DocFlavor determines how you load the document from the file. In this case, the representation class is an InputStream:

	FileInputStream fis = new FileInputStream("java2dlogo.gif");
Once you have the stream, pass it to SimpleDoc with the DocFlavor and a DocAttributeSet, ifi you have one. If you don't have a DocAttributeSet, pass in null instead:

	Doc doc = new SimpleDoc(fis, flavor, null);
See Example: PrintGIF.java for an example of a custom Doc implementation.

The next section demonstrates how to register for events on your print job or service.



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