class HexaPDF::Stream

Parent

Forward declaration of Stream to circumvent circular require problem

Implements Stream objects of the PDF object system.

Stream Objects

A stream may also be associated with a PDF object but only if the value is a PDF dictionary. This associated dictionary further describes the stream, like its length or how it is encoded.

Such a stream object in PDF contains string data but of possibly unlimited length. Therefore it is used for large amounts of data like images, page descriptions or embedded files.

The basic Object class cannot hold stream data, only this subclass contains the necessary methods to conveniently work with the stream data!

Note that support for external streams (/F, /FFilter, /FDecodeParms) is not yet implemented!

See: PDF2.0 s7.3.8, Dictionary

Field Definitions

NameType/Allowed ValuesRequiredDefault Value
LengthIntegerfalsenil
FilterSymbol or HexaPDF::PDFArray or Arrayfalsenil
DecodeParmsHexaPDF::Dictionary or HexaPDF::PDFArray or Hash or Arrayfalsenil
FHexaPDF::Type::FileSpecification or Hash or Stringfalsenil
FFilterSymbol or HexaPDF::PDFArray or Arrayfalsenil
FDecodeParmsHexaPDF::Dictionary or HexaPDF::PDFArray or Hash or Arrayfalsenil
DLIntegerfalsenil

Public Instance Methods

must_be_indirect?()

Stream objects must always be indirect.

raw_stream()

Returns the raw stream object.

The returned value can be of many different types (see stream=). For working with the decoded stream contents use stream.

set_filter(filter, decode_parms = nil)

Sets the filters that should be used for encoding the stream.

The arguments filter as well as decode_parms can either be a single items or arrays.

The filters have to be specified in the *decoding order*! For example, if the filters would be [:A85, :Fl], the stream would first be encoded with the Flate and then with the ASCII85 filter.

stream()

Returns the (possibly decoded) stream data as string.

Note that modifications done to the returned string are not reflected in the Stream object itself. The modified string must explicitly be assigned via stream= to take effect.

stream=(stream)

Assigns a new stream data object.

The stream argument can be a HexaPDF::StreamData object, a String object or nil.

If stream is nil, an empty binary string is used instead.

stream_decoder()

Returns the decoder Fiber for the stream data.

See the Filter module for more information on how to work with the fiber.

stream_encoder

Returns the encoder Fiber for the stream data.

See the Filter module for more information on how to work with the fiber.

stream_source()

Returns the Fiber representing the unprocessed content of the stream.