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]

: String

hash[RW]

: Hash[Symbol, untyped]

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.

: (Hash[Symbol, untyped], String) -> void

# File lib/pdf/reader/stream.rb, line 47
def initialize(hash, data)
  @hash = TypeCheck.cast_to_pdf_dict!(hash) #: Hash[Symbol, untyped]
  @data = data
  @udata = nil #: String | nil
end

Public Instance Methods

unfiltered_data() click to toggle source
apply this streams filters to its data and return the result.

: () -> String

# File lib/pdf/reader/stream.rb, line 55
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