Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.pdfbox.pdmodel.common
Class PDStream

    java.lang.Object
      org.pdfbox.pdmodel.common.PDStream

All Implemented Interfaces:
  COSObjectable

Direct Known Subclasses:
  PDMetadata, PDObjectStream

public class PDStream
extends Object
implements COSObjectable

A PDStream represents a stream in a PDF document. Streams are tied to a single PDF document.

Version:
  $Revision: 1.10 $
Author:
  Ben Litchfield (ben@csh.rit.edu)

Constructor Summary
`PDStream(COSStream str)` Constructor.
`PDStream(PDDocument document)` This will create a new PDStream object.
`PDStream(PDDocument doc, InputStream str, boolean filtered)` Constructor.

Method Summary
`void` | `addCompression()` If there are not compression filters on the current stream then this will add a compression filter, flate compression for example.
`static PDStream` | `createFromCOS(COSBase base)` Create a pd stream from either a regular COSStream on a COSArray of cos streams.
`InputStream` | `createInputStream()` This will get a stream that can be read from.
`OutputStream` | `createOutputStream()` This will get a stream that can be written to.
`byte[]` | `getByteArray()` This will copy the stream into a byte array.
`COSBase` | `getCOSObject()` Convert this standard java object to a COS object.
`List` | `getDecodeParams()` Get the list of decode parameters.
`PDFileSpecification` | `getFile()` This will get the file specification for this stream.
`List` | `getFileDecodeParams()` Get the list of decode parameters.
`List` | `getFileFilters()` This will get the list of filters that are associated with this stream.
`List` | `getFilters()` This will get the list of filters that are associated with this stream.
`int` | `getLength()` This will get the length of the filtered/compressed stream.
`PDMetadata` | `getMetadata()` Get the metadata that is part of the document catalog.
`InputStream` | `getPartiallyFilteredStream(List stopFilters)` This will get a stream with some filters applied but not others.
`COSStream` | `getStream()` Get the cos stream associated with this object.
`void` | `setDecodeParams(List decodeParams)` This will set the list of decode params.
`void` | `setFile(PDFileSpecification f)` Set the file specification.
`void` | `setFileDecodeParams(List decodeParams)` This will set the list of decode params.
`void` | `setFileFilters(List filters)` This will set the filters that are part of this stream.
`void` | `setFilters(List filters)` This will set the filters that are part of this stream.
`void` | `setMetadata(PDMetadata meta)` Set the metadata for this object.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PDStream

    public PDStream(PDDocument document)

  This will create a new PDStream object.

Parameters:
  `document` - The document that the stream will be part of.

### PDStream

    public PDStream(PDDocument doc,
                    InputStream str,
                    boolean filtered)
             throws IOException

  Constructor. Reads all data from the input stream and embeds it into the document, this will close the InputStream.

Parameters:
  `doc` - The document that will hold the stream.
  `str` - The stream parameter.
  `filtered` - True if the stream already has a filter applied.
Throws:
  `IOException` - If there is an error creating the stream in the document.

### PDStream

    public PDStream(COSStream str)

  Constructor.

Parameters:
  `str` - The stream parameter.

Method Detail

### addCompression

    public void addCompression()

  If there are not compression filters on the current stream then this will add a compression filter, flate compression for example.

### createFromCOS

    public static PDStream createFromCOS(COSBase base)
                                  throws IOException

  Create a pd stream from either a regular COSStream on a COSArray of cos streams.

  Parameters:
    `base` - Either a COSStream or COSArray.
  Returns:
    A PDStream or null if base is null.
  Throws:
    `IOException` - If there is an error creating the PDStream.

### getCOSObject

    public COSBase getCOSObject()

  Convert this standard java object to a COS object.

  Specified by:
    `getCOSObject` in interface `COSObjectable`
  Returns:
    The cos object that matches this Java object.

### createOutputStream

    public OutputStream createOutputStream()
                                    throws IOException

  This will get a stream that can be written to.

  Returns:
    An output stream to write data to.
  Throws:
    `IOException` - If an IO error occurs during writing.

### createInputStream

    public InputStream createInputStream()
                                  throws IOException

  This will get a stream that can be read from.

  Returns:
    An input stream that can be read from.
  Throws:
    `IOException` - If an IO error occurs during reading.

### getPartiallyFilteredStream

    public InputStream getPartiallyFilteredStream(List stopFilters)
                                           throws IOException

  This will get a stream with some filters applied but not others. This is useful when doing images, ie filters = [flate,dct], we want to remove flate but leave dct

  Parameters:
    `stopFilters` - A list of filters to stop decoding at.
  Returns:
    A stream with decoded data.
  Throws:
    `IOException` - If there is an error processing the stream.

### getStream

    public COSStream getStream()

  Get the cos stream associated with this object.

  Returns:
    The cos object that matches this Java object.

### getLength

    public int getLength()

  This will get the length of the filtered/compressed stream. This is readonly in the PD Model and will be managed by this class.

  Returns:
    The length of the filtered stream.

### getFilters

    public List getFilters()

  This will get the list of filters that are associated with this stream. Or null if there are none.

  Returns:
    A list of all encoding filters to apply to this stream.

### setFilters

    public void setFilters(List filters)

  This will set the filters that are part of this stream.

  Parameters:
    `filters` - The filters that are part of this stream.

### getDecodeParams

    public List getDecodeParams()
                         throws IOException

  Get the list of decode parameters. Each entry in the list will refer to an entry in the filters list.

  Returns:
    The list of decode parameters.
  Throws:
    `IOException` - if there is an error retrieving the parameters.

### setDecodeParams

    public void setDecodeParams(List decodeParams)

  This will set the list of decode params.

  Parameters:
    `decodeParams` - The list of decode params.

### getFile

    public PDFileSpecification getFile()

  This will get the file specification for this stream. This is only required for external files.

  Returns:
    The file specification.

### setFile

    public void setFile(PDFileSpecification f)

  Set the file specification.

  Parameters:
    `f` - The file specification.

### getFileFilters

    public List getFileFilters()

  This will get the list of filters that are associated with this stream. Or null if there are none.

  Returns:
    A list of all encoding filters to apply to this stream.

### setFileFilters

    public void setFileFilters(List filters)

  This will set the filters that are part of this stream.

  Parameters:
    `filters` - The filters that are part of this stream.

### getFileDecodeParams

    public List getFileDecodeParams()
                             throws IOException

  Get the list of decode parameters. Each entry in the list will refer to an entry in the filters list.

  Returns:
    The list of decode parameters.
  Throws:
    `IOException` - if there is an error retrieving the parameters.

### setFileDecodeParams

    public void setFileDecodeParams(List decodeParams)

  This will set the list of decode params.

  Parameters:
    `decodeParams` - The list of decode params.

### getByteArray

    public byte[] getByteArray()
                        throws IOException

  This will copy the stream into a byte array.

  Returns:
    The byte array of the filteredStream
  Throws:
    `IOException` - When getFilteredStream did not work

### getMetadata

    public PDMetadata getMetadata()

  Get the metadata that is part of the document catalog. This will return null if there is no meta data for this object.

  Returns:
    The metadata for this object.

### setMetadata

    public void setMetadata(PDMetadata meta)

  Set the metadata for this object. This can be null.

  Parameters:
    `meta` - The meta data for this object.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD