Class: PDF::Reader::ObjectStream

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/reader/object_stream.rb

Overview

provides a wrapper around a PDF stream object that contains other objects in it. This is done for added compression and is described as an “Object Stream” in the spec.

Instance Method Summary collapse

Constructor Details

#initialize(stream) ⇒ ObjectStream



9
10
11
12
# File 'lib/pdf/reader/object_stream.rb', line 9

def initialize(stream)
  @dict = stream.hash
  @data = stream.unfiltered_data
end

Instance Method Details

#[](objid) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/pdf/reader/object_stream.rb', line 14

def [](objid)
  if offsets[objid].nil?
    nil
  else
    buf = PDF::Reader::Buffer.new(StringIO.new(@data), :seek => offsets[objid])
    parser = PDF::Reader::Parser.new(buf)
    parser.parse_token
  end
end

#sizeObject



24
25
26
# File 'lib/pdf/reader/object_stream.rb', line 24

def size
  @dict[:N]
end