class PDF::Reader::XRef

def load_offsets(offset = nil)


or load_xref_stream() based on what we find there.
After seeking to the offset, processing is handed of to either load_xref_table()

default offset will be located and used.
If offset is specified the table will be loaded from there, otherwise the

Read a xref table from the underlying buffer.
###############################################################################
def load_offsets(offset = nil)
  offset ||= new_buffer.find_first_xref_offset
  offset += @junk_offset
  buf = new_buffer(offset)
  tok_one = buf.token
  return load_xref_table(buf) if tok_one == "xref" || tok_one == "ref"
  tok_two   = buf.token
  tok_three = buf.token
  if tok_one.to_i >= 0 && tok_two.to_i >= 0 && tok_three == "obj"
    buf = new_buffer(offset)
    stream = PDF::Reader::Parser.new(buf).object(tok_one.to_i, tok_two.to_i)
    return load_xref_stream(stream)
  end
  raise PDF::Reader::MalformedPDFError,
    "xref table not found at offset #{offset} (#{tok_one} != xref)"
end