Package org.apache.pdfbox.pdmodel.common
Class PDMemoryStream
java.lang.Object
org.apache.pdfbox.pdmodel.common.PDStream
org.apache.pdfbox.pdmodel.common.PDMemoryStream
- All Implemented Interfaces:
COSObjectable
A PDStream represents a stream in a PDF document. Streams are tied to a single
PDF document.
- Version:
- $Revision: 1.2 $
- Author:
- Ben Litchfield
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
If there are not compression filters on the current stream then this will add a compression filter, flate compression for example.This will get a stream that can be read from.This will get a stream that can be written to.byte[]
This will copy the stream into a byte array.Convert this standard java object to a COS object.Get the list of decode parameters.getFile()
This will get the file specification for this stream.Get the list of decode parameters.This will get the list of filters that are associated with this stream.This will get the list of filters that are associated with this stream.int
This will get the length of the filtered/compressed stream.Get the metadata that is part of the document catalog.getPartiallyFilteredStream
(List stopFilters) This will get a stream with some filters applied but not others.Get the cos stream associated with this object.void
setDecodeParams
(List decodeParams) This will set the list of decode params.void
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 org.apache.pdfbox.pdmodel.common.PDStream
createFromCOS, getDecodedStreamLength, getDecodeParms, getInputStreamAsString, setDecodedStreamLength, setDecodeParms
-
Constructor Details
-
PDMemoryStream
public PDMemoryStream(byte[] buffer) This will create a new PDStream object.- Parameters:
buffer
- The data for this in memory stream.
-
-
Method Details
-
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.- Overrides:
addCompression
in classPDStream
-
getCOSObject
Convert this standard java object to a COS object.- Specified by:
getCOSObject
in interfaceCOSObjectable
- Overrides:
getCOSObject
in classPDStream
- Returns:
- The cos object that matches this Java object.
-
createOutputStream
This will get a stream that can be written to.- Overrides:
createOutputStream
in classPDStream
- Returns:
- An output stream to write data to.
- Throws:
IOException
- If an IO error occurs during writing.
-
createInputStream
This will get a stream that can be read from.- Overrides:
createInputStream
in classPDStream
- Returns:
- An input stream that can be read from.
- Throws:
IOException
- If an IO error occurs during reading.
-
getPartiallyFilteredStream
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- Overrides:
getPartiallyFilteredStream
in classPDStream
- 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
Get the cos stream associated with this 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. -
getFilters
This will get the list of filters that are associated with this stream. Or null if there are none.- Overrides:
getFilters
in classPDStream
- Returns:
- A list of all encoding filters to apply to this stream.
-
setFilters
This will set the filters that are part of this stream.- Overrides:
setFilters
in classPDStream
- Parameters:
filters
- The filters that are part of this stream.
-
getDecodeParams
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
This will set the list of decode params.- Parameters:
decodeParams
- The list of decode params.
-
getFile
This will get the file specification for this stream. This is only required for external files. -
setFile
Set the file specification. -
getFileFilters
This will get the list of filters that are associated with this stream. Or null if there are none.- Overrides:
getFileFilters
in classPDStream
- Returns:
- A list of all encoding filters to apply to this stream.
-
setFileFilters
This will set the filters that are part of this stream.- Overrides:
setFileFilters
in classPDStream
- Parameters:
filters
- The filters that are part of this stream.
-
getFileDecodeParams
Get the list of decode parameters. Each entry in the list will refer to an entry in the filters list.- Overrides:
getFileDecodeParams
in classPDStream
- Returns:
- The list of decode parameters.
- Throws:
IOException
- if there is an error retrieving the parameters.
-
setFileDecodeParams
This will set the list of decode params.- Overrides:
setFileDecodeParams
in classPDStream
- Parameters:
decodeParams
- The list of decode params.
-
getByteArray
This will copy the stream into a byte array.- Overrides:
getByteArray
in classPDStream
- Returns:
- The byte array of the filteredStream
- Throws:
IOException
- When getFilteredStream did not work
-
getMetadata
Get the metadata that is part of the document catalog. This will return null if there is no meta data for this object.- Overrides:
getMetadata
in classPDStream
- Returns:
- The metadata for this object.
-
setMetadata
Set the metadata for this object. This can be null.- Overrides:
setMetadata
in classPDStream
- Parameters:
meta
- The meta data for this object.
-