class PDF::Reader::Filter

in the future.
Currently only 1 filter type is supported. Hopefully support for others will be added
content.
support for features like compression and encryption. This class is for decoding that
Various parts of a PDF file can be passed through a filter before being stored to provide
###############################################################################

def filter (data)

attempts to decode the specified data with the current filter
###############################################################################
def filter (data)
  # leave the data untouched if we don't support the required filter
  return data if @filter.nil?
  # decode the data
  self.send(@filter, data)
end

def flate (data)

Decode the specified data with the Zlib compression algorithm
###############################################################################
def flate (data)
  begin
    z = Zlib::Inflate.new
    z.inflate(data)
  rescue Exception => e
    raise MalformedPDFError, "Error occured while inflating a compressed stream (#{e.class.to_s}: #{e.to_s})"
  end
end

def initialize (name, options)

creates a new filter for decoding content
###############################################################################
def initialize (name, options)
  @options = options
  case name
  when "FlateDecode"    then @filter = :flate
  #else                    raise UnsupportedFeatureError, "Unknown filter: #{name}"
  end
end