gnu.jpdf
Class PDFStream

java.lang.Object
  extended by gnu.jpdf.PDFObject
      extended by gnu.jpdf.PDFStream
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
PDFImage

public class PDFStream
extends PDFObject
implements java.io.Serializable

This class implements a PDF stream object. In PDF, streams contain data like the graphic operators that render a page, or the pixels of an image.

In PDF, a stream can be compressed using several different methods, or left uncompressed. Here we support both uncompressed, and FlateDecode as it's supported by the java core.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class gnu.jpdf.PDFObject
objser, pdfDocument
 
Constructor Summary
PDFStream()
          Constructs a plain stream.
PDFStream(java.lang.String type)
          Constructs a stream.
 
Method Summary
 boolean getDeflate()
          Returs true if the stream will be compressed.
 java.io.OutputStream getOutputStream()
          Returns the OutputStream that will append to this stream.
 java.io.ByteArrayOutputStream getStream()
          This is for extenders, and provides access to the stream.
 java.io.PrintWriter getWriter()
          Creates a PrintWriter that will append to this stream.
 void setDeflate(boolean mode)
           
 void write(java.io.OutputStream os)
          Writes the object to the output stream.
 void writeStream(java.io.OutputStream os)
          This inserts the Streams length, then the actual stream, finally the end of stream/object markers.
 
Methods inherited from class gnu.jpdf.PDFObject
getPDFDocument, getSerialID, getType, toArray, toString, writeEnd, writeStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PDFStream

public PDFStream()
Constructs a plain stream.

By default, the stream will be compressed.


PDFStream

public PDFStream(java.lang.String type)
Constructs a stream. The supplied type is stored in the stream's header and is used by other objects that extend the PDFStream class (like PDFImage).

By default, the stream will be compressed.

Parameters:
type - type for the stream
See Also:
PDFImage
Method Detail

setDeflate

public void setDeflate(boolean mode)
Parameters:
mode - true will FlatDecode the stream

getDeflate

public boolean getDeflate()
Returs true if the stream will be compressed.

Returns:
true if compression is enabled

getOutputStream

public java.io.OutputStream getOutputStream()
Returns the OutputStream that will append to this stream.

Returns:
The stream for this object

getWriter

public java.io.PrintWriter getWriter()
Creates a PrintWriter that will append to this stream.

Returns:
a PrintWriter to write to the stream

getStream

public java.io.ByteArrayOutputStream getStream()
This is for extenders, and provides access to the stream.

Returns:
ByteArrayOutputStream containing the contents.

write

public void write(java.io.OutputStream os)
           throws java.io.IOException
Description copied from class: PDFObject

Writes the object to the output stream. This method must be overidden.

Note: It should not write any other objects, even if they are it's Kids, as they will be written by the calling routine.

Specified by:
write in class PDFObject
Parameters:
os - OutputStream to send the object to
Throws:
java.io.IOException - on error

writeStream

public void writeStream(java.io.OutputStream os)
                 throws java.io.IOException
This inserts the Streams length, then the actual stream, finally the end of stream/object markers.

This is intended for anyone extending PDFStream, as objects containing streams do no use writeEnd(), and they must be able to write the actual stream.

Parameters:
os - OutputStream to send the object to
Throws:
java.io.IOException - on error