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

:nodoc:



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

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

Instance Method Details

#[](objid) ⇒ Object



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

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



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

def size
  @dict[:N]
end