Class PDF::Reader::Buffer
In: lib/pdf/reader/buffer.rb
Parent: Object

A string tokeniser that recognises PDF grammar. When passed an IO stream or a string, repeated calls to token() will return the next token from the source.

This is very low level, and getting the raw tokens is not very useful in itself.

This will usually be used in conjunction with PDF:Reader::Parser, which converts the raw tokens into objects we can work with (strings, ints, arrays, etc)

Methods

Constants

TOKEN_WHITESPACE = ["\x00", "\x09", "\x0A", "\x0C", "\x0D", "\x20"]

Attributes

pos  [R] 

Public Class methods

Creates a new buffer.

Params:

  io - an IO stream or string with the raw data to tokenise

options:

  :seek - a byte offset to seek to before starting to tokenise
  :content_stream - set to true if buffer will be tokenising a
                    content stream. Defaults to false

Public Instance methods

return true if there are no more tokens left

return the byte offset where the first XRef table in th source can be found.

return raw bytes from the underlying IO stream.

  bytes - the number of bytes to read

options:

  :skip_eol - if true, the IO stream is advanced past a CRLF or LF that
              is sitting under the io cursor.

return the next token from the source. Returns a string if a token is found, nil if there are no tokens left.

[Validate]