CONTENTS | PREV | NEXT JavaTM Print Service API User Guide


Client-Formatted Print Data

The client uses the DocFlavor to describe the print data format and to indicate how the data will be delivered to the print service. The MIME type specifies the data format. The representation class name specifies how the data will be delivered to the printer.

The DocFlavor class has an inner class for each of the common representation class names. Each inner class contains a set of DocFlavor object constants representing formats that can be delivered using the representation class. For example, an input stream can stream many different kinds of print data formats, including GIF, represented by DocFlavor.INPUT_STREAM.GIF, and PostScriptTM, represented by DocFlavor.INPUT_STREAM.POSTSCRIPT. If one of the DocFlavor object constants accurately describes the format of a given piece of print data, the client can use this constant instead of constructing a DocFlavor.

If the appropriate DocFlavor is not already defined in the JPS API, a client can create it with the DocFlavor constructor. The client can use the MIME types and representation class names explained in the next two sections to construct the DocFlavor.


MIME Types for Preformatted Data

The four most common types of preformatted data are: text data, page description language documents, image data, and autosense print data. This section describes each one of these data types and lists their corresponding MIME types.


Text Data

Preformatted text data is usually provided in a character-oriented representation class, such as a character array, String, or Reader, or in a byte-oriented representation class, such as a byte array, input stream, or URL. Plain text and HTML are two common forms of preformatted text data. You can use these MIME type strings to represent the format of the data when constructing a DocFlavor:

MIME type Format of data

"text/plain"

Plain text in the default character set US-ASCII

"text/plain;charset=xxx"

Plain text in character set xxx

"text/html"

HyperText Markup Languge in the default character set (US-ASCII)

"text/html;charset=xxx"

HyperText Markup Languge in the character set xxx


Page Description Language Documents

Preformatted page description language (PDL) documents are usually provided in a byte-oriented representation class, such as byte array, InputStream, or URL. You can use these MIME type strings to represent the format of the data when constructing a DocFlavor:

MIME type Format of data

"application/pdf"

Portable Document Format document

"application/postscript"

PostScriptTM document

"application/vnd.hp-PCL"

Printer Control Language document


Image Data

Preformatted image data is provided in a byte-oriented representation class: byte array, InputStream, or URL. You can use these MIME type strings to represent the format of the data when constructing a DocFlavor:

MIME type Format of data
"image/gif"

Graphics Interchange Format image

"image/jpeg"

Joint Photographic Experts Group image

"image/png"

Portable Network Graphics image


Autosense Print Data

Preformatted autosense print data allows the printer to decide how to interpret the print data. This type of data is usually provided in a byte-oriented representation class. You can use this MIME type string to represent the format of the data when constructing a DocFlavor:

"application/octet-stream"


Representation Classes

For client-formatted print data, the print data representation class is usually one of the following:

Print data representation class Description

Character array (char[])

The print data consists of the Unicode characters in the array. This representation class can provide text data and PDL data.

java.lang.String

The print data consists of the Unicode characters in the string. This representation class can provide text data.

A Character stream represented by java.io.Reader

The print data consists of the Unicode characters read from the stream up to the end-of-stream. This representation class can provide text data.

Byte array (byte[])

The print data consists of the bytes in the array. The bytes are encoded in the character set specified by the doc flavor's MIME type. If the MIME type does not specify a character set, the default character set is US-ASCII. This representation class can provide text data, PDL documents, and image data.

A Byte stream represented by java.io.InputStream

The print data consists of the bytes read from the stream up to the end-of-stream. The bytes are encoded in the character set specified by the doc flavor's MIME type. If the MIME type does not specify a character set, the default character set is US-ASCII. This representation class can provide text data, PDL documents, and image data.

Uniform Resource Locator, java.net.URL

The print data consists of the bytes read from the URL location. The bytes are encoded in the character set specified by the doc flavor's MIME type. If the MIME type does not specify a character set, the default character set is US-ASCII. This representation class can provide text data, PDL documents, and image data. To print documents to a network print service that might not have access to the URL, open an input stream on the URL and use an input stream data flavor instead.



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