java.lang.Object
org.sejda.sambox.pdmodel.common.PDStream
- All Implemented Interfaces:
COSObjectable
- Direct Known Subclasses:
PDEmbeddedFile,PDMetadata,PDObjectStream
A PDStream represents a stream in a PDF document. Streams are tied to a single PDF document.
- Author:
- Ben Litchfield
-
Constructor Summary
ConstructorsConstructorDescriptionPDStream()This will create a new PDStream object.PDStream(InputStream input) Constructor.PDStream(InputStream input, COSArray filters) Constructor.PDStream(InputStream input, COSBase filter) Constructor.PDStream(InputStream input, COSName filter) Constructor.Constructor. -
Method Summary
Modifier and TypeMethodDescriptionThis will get a stream that can be read from.This will get a stream that can be written to.createOutputStream(COSName filter) This will get a stream that can be written to, with the given filter.Convert this standard java object to a COS object.intGet the decoded stream length.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.intThis will get the length of the filtered/compressed stream.Get the metadata that is part of the document catalog.voidsetDecodedStreamLength(int decodedStreamLength) Set the decoded stream length.voidsetDecodeParms(List<?> decodeParams) This will set the list of decode parameterss.voidSet the file specification.voidsetFileDecodeParams(List<?> decodeParams) This will set the list of decode params.voidsetFileFilters(List<String> filters) This will set the filters that are part of this stream.voidsetFilters(List<COSName> filters) This will set the filters that are part of this stream.voidsetMetadata(PDMetadata meta) Set the metadata for this object.byte[]This will copy the stream into a byte array.
-
Constructor Details
-
PDStream
public PDStream()This will create a new PDStream object. -
PDStream
Constructor.- Parameters:
str- The stream parameter.
-
PDStream
Constructor. Reads all data from the input stream and embeds it into the document, this will close the InputStream.- Parameters:
input- The stream parameter.- Throws:
IOException- If there is an error creating the stream in the document.
-
PDStream
Constructor. Reads all data from the input stream and embeds it into the document with the given filter applied. This method closes the InputStream.- Parameters:
input- The stream parameter.filter- Filter to apply to the stream.- Throws:
IOException- If there is an error creating the stream in the document.
-
PDStream
Constructor. Reads all data from the input stream and embeds it into the document with the given filters applied. This method closes the InputStream.- Parameters:
input- The stream parameter.filters- Filters to apply to the stream.- Throws:
IOException- If there is an error creating the stream in the document.
-
PDStream
Constructor. Reads all data from the input stream and embeds it into the document, this will close the InputStream.- Parameters:
input- The stream parameter.filter- Filter to apply to the stream.- Throws:
IOException- If there is an error creating the stream in the document.
-
-
Method Details
-
getCOSObject
Convert this standard java object to a COS object.- Specified by:
getCOSObjectin interfaceCOSObjectable- Returns:
- The cos object that matches this Java object.
-
createOutputStream
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.
-
createOutputStream
This will get a stream that can be written to, with the given filter.- Parameters:
filter- the filter to be used.- 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.- Returns:
- An input stream that can be read from.
- Throws:
IOException- If an IO error occurs during reading.
-
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
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
This will set the filters that are part of this stream.- Parameters:
filters- The filters that are part of this stream.
-
getDecodeParms
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.
-
setDecodeParms
This will set the list of decode parameterss.- Parameters:
decodeParams- The list of decode parameterss.
-
getFile
This will get the file specification for this stream. This is only required for external files.- Returns:
- The file specification.
-
setFile
Set the file specification.- Parameters:
f- The file specification.
-
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
This will set the filters that are part of this stream.- 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.- 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.- Parameters:
decodeParams- The list of decode params.
-
toByteArray
This will copy the stream into a byte array.- 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.- Returns:
- The metadata for this object.
- Throws:
IllegalStateException- if the value of the metadata entry is different from a stream or null
-
setMetadata
Set the metadata for this object. This can be null.- Parameters:
meta- The meta data for this object.
-
getDecodedStreamLength
public int getDecodedStreamLength()Get the decoded stream length.- Returns:
- the decoded stream length
- Since:
- Apache PDFBox 1.1.0
- See Also:
-
setDecodedStreamLength
public void setDecodedStreamLength(int decodedStreamLength) Set the decoded stream length.- Parameters:
decodedStreamLength- the decoded stream length- Since:
- Apache PDFBox 1.1.0
- See Also:
-