Class: PDF::Reader::Filter
- Inherits:
-
Object
- Object
- PDF::Reader::Filter
- Defined in:
- lib/pdf/reader/filter.rb
Overview
Various parts of a PDF file can be passed through a filter before being stored to provide support for features like compression and encryption. This class is for decoding that content.
Currently only 1 filter type is supported. Hopefully support for others will be added in the future.
Instance Method Summary collapse
-
#filter(data) ⇒ Object
attempts to decode the specified data with the current filter.
-
#flate(data) ⇒ Object
Decode the specified data with the Zlib compression algorithm.
-
#initialize(name, options) ⇒ Filter
constructor
creates a new filter for decoding content.
Constructor Details
#initialize(name, options) ⇒ Filter
creates a new filter for decoding content
38 39 40 41 42 43 44 45 |
# File 'lib/pdf/reader/filter.rb', line 38 def initialize (name, ) @options = case name when "FlateDecode" then @filter = :flate else raise UnsupportedFeatureError, "Unknown filter: #{name}" end end |
Instance Method Details
#filter(data) ⇒ Object
attempts to decode the specified data with the current filter
48 49 50 |
# File 'lib/pdf/reader/filter.rb', line 48 def filter (data) self.send(@filter, data) end |
#flate(data) ⇒ Object
Decode the specified data with the Zlib compression algorithm
53 54 55 56 57 |
# File 'lib/pdf/reader/filter.rb', line 53 def flate (data) z = Zlib::Inflate.new z << data z.inflate(nil) end |