Class COSStream

  • All Implemented Interfaces:
    COSObjectable

    public class COSStream
    extends COSDictionary
    A PDF stream object: a COSDictionary (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 /Filter on demand via getDecodedBytes(), caching the result.
    • Constructor Detail

      • COSStream

        public COSStream()
    • 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,
                                      COSException
        Applies every filter in the /Filter chain (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 as DCTDecode), 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.IOException
        COSException
      • isFullyDecodable

        public boolean isFullyDecodable()
        True if every filter named by /Filter is understood by this API's FilterFactory, 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,
                                  COSException
        Convenience for new String(getDecodedBytes(), ...)-style access to content streams.
        Throws:
        java.io.IOException
        COSException