class PDF::Reader::Stream

An internal PDF::Reader class that represents a stream object from a PDF. Stream objects have 2 components, a dictionary that describes the content (size, compression, etc) and a stream of bytes.

Attributes

data[RW]
hash[RW]

Public Class Methods

new(hash, data) click to toggle source

Creates a new stream with the specified dictionary and data. The dictionary should be a standard ruby hash, the data should be a standard ruby string.

# File lib/pdf/reader/stream.rb, line 42
def initialize(hash, data)
  @hash = TypeCheck.cast_to_pdf_dict!(hash)
  @data = data
  @udata = nil
end

Public Instance Methods

unfiltered_data() click to toggle source

apply this streams filters to its data and return the result.

# File lib/pdf/reader/stream.rb, line 49
def unfiltered_data
  return @udata if @udata
  @udata = data.dup

  if hash.has_key?(:Filter)
    options = []

    if hash.has_key?(:DecodeParms)
      if hash[:DecodeParms].is_a?(Hash)
        options = [hash[:DecodeParms]]
      else
        options = hash[:DecodeParms]
      end
    end

    Array(hash[:Filter]).each_with_index do |filter, index|
      @udata = Filter.with(filter, options[index] || {}).filter(@udata)
    end
  end
  @udata
end