Class PDFStream

java.lang.Object
com.datalogics.PDFL.PDFObject
com.datalogics.PDFL.PDFStream

public class PDFStream extends PDFObject
Represents a stream of data within a PDF document. All objects in a PDF document are built from a collection of simpler objects that represent fundamental datatypes like numbers, strings and arrays.

PDFObject and its subclasses allow direct access and manipulation of these simple objects. Some subclasses represent single data elements (e.g. PDFInteger represents a single integer value); other subclasses represent a collection of PDFObjects (e.g. PDFArray is an indexed array of data elements).

A PDFStream represents a stream of unsigned bytes, and may be inserted into any collection object. It includes a dictionary that describes how the data in the stream is encoded and other useful information about the stream. A PDFStream is always an indirect object.

PDFStreams can be encoded using built-in filters. These filters include compression schemes for most popular image formats, and text encoding translators to permit safe transmission of the document over the Internet. The data in a PDFStream will be automatically encoded when it is created; the user can read either the encoded (raw) or decoded (filtered) data.

PDFStreams can be used for any large collection of data that need not be read into memory all at once, including image data, multimedia data or XML markup.

  • Constructor Details

    • PDFStream

      public PDFStream(InputStream stream, Document doc, PDFDict encoding_dict, PDFArray encoding_params)
      General constructor
      Parameters:
      stream - java.io.InputStream which will provide data for this PDFStream
      doc - Document object containing this PDFStream
      encoding_dict - PDFDict describing properties of this stream, including the encoding
      encoding_params - PDFArray describing parameters for encoding this stream
    • PDFStream

      public PDFStream(InputStream stream, PDFObject docFromObj, PDFDict encoding_dict, PDFArray encoding_params)
      General constructor
      Parameters:
      stream - java.io.InputStream which will provide data for this PDFStream
      docFromObj - The new PDFArray will be created in the same document as this object.
      encoding_dict - PDFDict describing properties of this stream, including the encoding
      encoding_params - PDFArray describing parameters for encoding this stream
  • Method Details

    • delete

      public void delete()
      Overrides:
      delete in class PDFObject
    • getStream

      public InputStream getStream(PDFStreamOpenMode mode)
      The stream data of this object, processed according to the mode
      Parameters:
      mode - the open mode with which to read this stream
    • getFilteredStream

      public InputStream getFilteredStream()
      The stream data of this object, decoded according to the filter data in its dictionary.
    • getUnfilteredStream

      public InputStream getUnfilteredStream()
      The unfiltered data of this stream object.
    • SetData

      public void SetData(InputStream stream, PDFDict encoding_dict, PDFArray encoding_params)
      Replace the data in this PDFStream
      Parameters:
      stream - java.io.InputStream which will provide data for this PDFStream
      encoding_dict - PDFDict describing properties of this stream, including the encoding
      encoding_params - PDFArray describing parameters for encoding this stream
    • toString

      public String toString()
      Overrides:
      toString in class PDFObject
    • getDict

      public PDFDict getDict()
      The encoding dictionary for the stream. This includes all required information for decoding the stream.

    • getLength

      public int getLength()
      The encoded length of the stream.

    • getStreamPos

      public int getStreamPos()
      The byte offset of this stream in the PDF file.