Class COSStream

    • Constructor Detail

      • COSStream

        public COSStream()
        Creates a new stream with an empty dictionary.
      • COSStream

        public COSStream​(ScratchFile scratchFile)
        Creates a new stream with an empty dictionary. Data is stored in the given scratch file.
        Parameters:
        scratchFile - Scratch file for writing stream data.
    • Method Detail

      • createRawInputStream

        public InputStream createRawInputStream()
                                         throws IOException
        Returns a new InputStream which reads the encoded PDF stream data. Experts only!
        Returns:
        InputStream containing raw, encoded PDF stream data.
        Throws:
        IOException - If the stream could not be read.
      • createInputStream

        public COSInputStream createInputStream()
                                         throws IOException
        Returns a new InputStream which reads the decoded stream data.
        Returns:
        InputStream containing raw, decoded stream data.
        Throws:
        IOException - If the stream could not be read.
      • createUnfilteredStream

        @Deprecated
        public OutputStream createUnfilteredStream()
                                            throws IOException
        Deprecated.
        This will create an output stream that can be written to.
        Returns:
        An output stream which raw data bytes should be written to.
        Throws:
        IOException - If there is an error creating the stream.
      • createOutputStream

        public OutputStream createOutputStream()
                                        throws IOException
        Returns a new OutputStream for writing stream data, using the current filters.
        Returns:
        OutputStream for un-encoded stream data.
        Throws:
        IOException - If the output stream could not be created.
      • createOutputStream

        public OutputStream createOutputStream​(COSBase filters)
                                        throws IOException
        Returns a new OutputStream for writing stream data, using and the given filters.
        Parameters:
        filters - COSArray or COSName of filters to be used.
        Returns:
        OutputStream for un-encoded stream data.
        Throws:
        IOException - If the output stream could not be created.
      • createFilteredStream

        @Deprecated
        public OutputStream createFilteredStream()
                                          throws IOException
        Deprecated.
        This will create a new stream for which filtered byte should be written to. You probably don't want this but want to use the createUnfilteredStream, which is used to write raw bytes to.
        Returns:
        A stream that can be written to.
        Throws:
        IOException - If there is an error creating the stream.
      • createRawOutputStream

        public OutputStream createRawOutputStream()
                                           throws IOException
        Returns a new OutputStream for writing encoded PDF data. Experts only!
        Returns:
        OutputStream for raw PDF stream data.
        Throws:
        IOException - If the output stream could not be created.
      • getLength

        public long getLength()
        Returns the length of the encoded stream.
        Returns:
        length in bytes
      • getFilters

        public COSBase getFilters()
        This will return the filters to apply to the byte stream. The method will return - null if no filters are to be applied - a COSName if one filter is to be applied - a COSArray containing COSNames if multiple filters are to be applied
        Returns:
        the COSBase object representing the filters
      • setFilters

        @Deprecated
        public void setFilters​(COSBase filters)
                        throws IOException
        Deprecated.
        Sets the filters to be applied when encoding or decoding the stream.
        Parameters:
        filters - The filters to set on this stream.
        Throws:
        IOException - If there is an error clearing the old filters.
      • toTextString

        public String toTextString()
        Returns the contents of the stream as a PDF "text string".
      • accept

        public Object accept​(ICOSVisitor visitor)
                      throws IOException
        Description copied from class: COSDictionary
        visitor pattern double dispatch method.
        Overrides:
        accept in class COSDictionary
        Parameters:
        visitor - The object to notify when visiting this object.
        Returns:
        The object that the visitor returns.
        Throws:
        IOException - If there is an error visiting this object.