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:



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

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

Instance Method Details

#[](objid) ⇒ Object



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

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



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

def size
  TypeCheck.cast_to_int!(@dict[:N])
end