org.apache.fop.pdf
Class PDFStream

java.lang.Object
  extended byorg.apache.fop.pdf.PDFObject
      extended byorg.apache.fop.pdf.PDFStream
Direct Known Subclasses:
PDFCMap, PDFICCStream, PDFT1Stream, PDFTTFStream

public class PDFStream
extends PDFObject

class representing a PDF stream. A derivative of the PDF Object, a PDF Stream has not only a dictionary but a stream of PDF commands. The stream of commands is where the real work is done, the dictionary just provides information like the stream length.


Field Summary
protected  java.io.ByteArrayOutputStream _data
          the stream of PDF commands
 
Fields inherited from class org.apache.fop.pdf.PDFObject
generation, number
 
Constructor Summary
PDFStream(int number)
          create an empty stream object
 
Method Summary
 void add(java.lang.String s)
          append data to the stream
protected  void addDefaultFilters()
           
 void addFilter(PDFFilter filter)
          Add a filter for compression of the stream.
 void addFilter(java.lang.String filterType)
           
 void addImageArray(int[] pixels, int width, int height)
          append an array of xRGB pixels, ASCII Hex Encoding it first
protected  java.lang.String applyFilters()
          Apply the filters to the data in the order given and return the /Filter and /DecodeParms entries for the stream dictionary.
 byte[] getData()
           
 int getDataLength()
           
protected  int output(java.io.OutputStream stream)
          write the PDF represention of this object
protected  int outputStreamData(java.io.OutputStream stream)
          Output just the stream data enclosed by stream/endstream markers
 void setData(byte[] data)
           
 byte[] toPDF()
          represent as PDF.
 
Methods inherited from class org.apache.fop.pdf.PDFObject
getNumber, referencePDF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_data

protected java.io.ByteArrayOutputStream _data
the stream of PDF commands

Constructor Detail

PDFStream

public PDFStream(int number)
create an empty stream object

Parameters:
number - the object's number
Method Detail

add

public void add(java.lang.String s)
append data to the stream

Parameters:
s - the string of PDF to add

addFilter

public void addFilter(PDFFilter filter)
Add a filter for compression of the stream. Filters are applied in the order they are added. This should always be a new instance of the particular filter of choice. The applied flag in the filter is marked true after it has been applied to the data.


addFilter

public void addFilter(java.lang.String filterType)

addDefaultFilters

protected void addDefaultFilters()

addImageArray

public void addImageArray(int[] pixels,
                          int width,
                          int height)
append an array of xRGB pixels, ASCII Hex Encoding it first

Parameters:
pixels - the area of pixels
width - the width of the image in pixels
height - the height of the image in pixels

setData

public void setData(byte[] data)
             throws java.io.IOException
Throws:
java.io.IOException

getData

public byte[] getData()

getDataLength

public int getDataLength()

toPDF

public byte[] toPDF()
represent as PDF.

Returns:
the PDF string.

output

protected int output(java.io.OutputStream stream)
              throws java.io.IOException
Description copied from class: PDFObject
write the PDF represention of this object

Overrides:
output in class PDFObject
Parameters:
stream - the stream to write the PDF to
Returns:
the number of bytes written
Throws:
java.io.IOException

outputStreamData

protected int outputStreamData(java.io.OutputStream stream)
                        throws java.io.IOException
Output just the stream data enclosed by stream/endstream markers

Throws:
java.io.IOException

applyFilters

protected java.lang.String applyFilters()
                                 throws java.io.IOException
Apply the filters to the data in the order given and return the /Filter and /DecodeParms entries for the stream dictionary. If the filters have already been applied to the data (either externally, or internally) then the dictionary entries are built and returned.

Throws:
java.io.IOException


Copyright © 1999-2003 Apache Software Foundation. All Rights Reserved.