org.pdfbox.pdmodel.common
Class PDMemoryStream
- COSObjectable
public class PDMemoryStream
A PDStream represents a stream in a PDF document. Streams are tied to a single
PDF document.
addCompression , createFromCOS , createInputStream , createOutputStream , getByteArray , getCOSObject , getDecodeParams , getFile , getFileDecodeParams , getFileFilters , getFilters , getInputStreamAsString , getLength , getMetadata , getPartiallyFilteredStream , getStream , setDecodeParams , setFile , setFileDecodeParams , setFileFilters , setFilters , setMetadata |
PDMemoryStream
public PDMemoryStream(byte[] buffer)
This will create a new PDStream object.
buffer
- The data for this in memory stream.
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.
- addCompression in interface PDStream
createInputStream
public InputStream createInputStream()
throws IOException
This will get a stream that can be read from.
- createInputStream in interface PDStream
- An input stream that can be read from.
createOutputStream
public OutputStream createOutputStream()
throws IOException
This will get a stream that can be written to.
- createOutputStream in interface PDStream
- An output stream to write data to.
getByteArray
public byte[] getByteArray()
throws IOException
This will copy the stream into a byte array.
- getByteArray in interface PDStream
- The byte array of the filteredStream
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.
- getDecodeParams in interface PDStream
- The list of decode parameters.
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.
- getFileDecodeParams in interface PDStream
- The list of decode parameters.
getFileFilters
public List getFileFilters()
This will get the list of filters that are associated with this stream. Or
null if there are none.
- getFileFilters in interface PDStream
- A list of all encoding filters to apply to this stream.
getFilters
public List getFilters()
This will get the list of filters that are associated with this stream. Or
null if there are none.
- getFilters in interface PDStream
- A list of all encoding filters to apply to this stream.
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.
- getLength in interface PDStream
- The length of the filtered stream.
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.
- getMetadata in interface PDStream
- The metadata for this object.
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
- getPartiallyFilteredStream in interface PDStream
stopFilters
- A list of filters to stop decoding at.
- A stream with decoded data.
getStream
public COSStream getStream()
Get the cos stream associated with this object.
- getStream in interface PDStream
- The cos object that matches this Java object.
setDecodeParams
public void setDecodeParams(List decodeParams)
This will set the list of decode params.
- setDecodeParams in interface PDStream
decodeParams
- The list of decode params.
setFileDecodeParams
public void setFileDecodeParams(List decodeParams)
This will set the list of decode params.
- setFileDecodeParams in interface PDStream
decodeParams
- The list of decode params.
setFileFilters
public void setFileFilters(List filters)
This will set the filters that are part of this stream.
- setFileFilters in interface PDStream
filters
- The filters that are part of this stream.
setFilters
public void setFilters(List filters)
This will set the filters that are part of this stream.
- setFilters in interface PDStream
filters
- The filters that are part of this stream.
setMetadata
public void setMetadata(PDMetadata meta)
Set the metadata for this object. This can be null.
- setMetadata in interface PDStream
meta
- The meta data for this object.