Package com.pd4ml.pdf.cos
Class COSStream
- java.lang.Object
-
- com.pd4ml.pdf.cos.COSBase
-
- com.pd4ml.pdf.cos.COSDictionary
-
- com.pd4ml.pdf.cos.COSStream
-
- All Implemented Interfaces:
COSObjectable
public class COSStream extends COSDictionary
A PDF stream object: aCOSDictionary(the "stream dictionary") together with a run of raw bytes. This class holds the raw, still encoded bytes as parsed from the file and applies the filter chain named by/Filteron demand viagetDecodedBytes(), caching the result.
-
-
Constructor Summary
Constructors Constructor Description COSStream()COSStream(COSDictionary dictionary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(ICOSVisitor<T> visitor)byte[]getDecodedBytes()Applies every filter in the/Filterchain (in order, feeding each filter's output to the next) and returns the fully decoded bytes.java.util.List<COSName>getFilterNames()byte[]getRawData()booleanisFullyDecodable()True if every filter named by/Filteris understood by this API'sFilterFactory, i.e.voidsetRawData(byte[] rawData)Sets the raw (still filtered/encoded) bytes exactly as they appear between "stream" and "endstream".byte[]toByteArray()Convenience fornew String(getDecodedBytes(), ...)-style access to content streams.java.lang.StringtoString()-
Methods inherited from class com.pd4ml.pdf.cos.COSDictionary
containsKey, containsKey, entrySet, equals, getArray, getBoolean, getCOSName, getDictionary, getDictionaryObject, getDictionaryObject, getDictionaryObject, getFloat, getInt, getItem, getItem, getLong, getNameAsString, getStream, getString, hashCode, isEmpty, keySet, removeItem, setBoolean, setFloat, setInt, setItem, setItem, setName, setString, size
-
Methods inherited from class com.pd4ml.pdf.cos.COSBase
getCOSObject, getGenerationNumber, getKey, getObjectNumber, isDirect, resolve, setKey
-
-
-
-
Constructor Detail
-
COSStream
public COSStream()
-
COSStream
public COSStream(COSDictionary dictionary)
-
-
Method Detail
-
setRawData
public void setRawData(byte[] rawData)
Sets the raw (still filtered/encoded) bytes exactly as they appear between "stream" and "endstream".
-
getRawData
public byte[] getRawData()
-
getDecodedBytes
public byte[] getDecodedBytes() throws java.io.IOException, COSExceptionApplies every filter in the/Filterchain (in order, feeding each filter's output to the next) and returns the fully decoded bytes. If a filter is unsupported (e.g. an image codec such asDCTDecode), decoding stops there and the partially decoded bytes are returned -- this mirrors what most PDF consumers want, since such filters usually sit last in the chain, right before consumption by an image decoder that understands that specific codec directly.- Throws:
java.io.IOExceptionCOSException
-
isFullyDecodable
public boolean isFullyDecodable()
True if every filter named by/Filteris understood by this API'sFilterFactory, i.e.getDecodedBytes()will return fully decoded data rather than stopping partway through the chain.
-
getFilterNames
public java.util.List<COSName> getFilterNames()
-
toByteArray
public byte[] toByteArray() throws java.io.IOException, COSExceptionConvenience fornew String(getDecodedBytes(), ...)-style access to content streams.- Throws:
java.io.IOExceptionCOSException
-
accept
public <T> T accept(ICOSVisitor<T> visitor) throws COSException
- Overrides:
acceptin classCOSDictionary- Throws:
COSException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classCOSDictionary
-
-