Class: PDF::Reader::Parser

### Home Classes Methods

### In Files

- lib/pdf/reader/parser.rb

### Parent

Object

### Methods

- ::new
- #object
- #parse_token

### Files

- MIT-LICENSE
- README.rdoc
- TODO
- mac_expert.txt
- mac_roman.txt
- pdf_doc.txt
- standard.txt
- symbol.txt
- win_ansi.txt
- zapf_dingbats.txt
- glyphlist.txt

### Class/Module Index

Quicksearch

- PDF
- PDF::Reader
- PDF::Reader::Buffer
- PDF::Reader::CidWidths
- PDF::Reader::EncryptedPDFError
- PDF::Reader::Filter
- PDF::Reader::Filter::Ascii85
- PDF::Reader::Filter::AsciiHex
- PDF::Reader::Filter::Depredict
- PDF::Reader::Filter::Flate
- PDF::Reader::Filter::Lzw
- PDF::Reader::Filter::Null
- PDF::Reader::Filter::RunLength
- PDF::Reader::Font
- PDF::Reader::FontDescriptor
- PDF::Reader::FormXObject
- PDF::Reader::InvalidObjectError
- PDF::Reader::MalformedPDFError
- PDF::Reader::ObjectCache
- PDF::Reader::ObjectHash
- PDF::Reader::PageLayout
- PDF::Reader::PageState
- PDF::Reader::PageTextReceiver
- PDF::Reader::Parser
- PDF::Reader::PrintReceiver
- PDF::Reader::Reference
- PDF::Reader::RegisterReceiver
- PDF::Reader::ResourceMethods
- PDF::Reader::StandardSecurityHandler
- PDF::Reader::Stream
- PDF::Reader::SynchronizedCache
- PDF::Reader::TextReceiver
- PDF::Reader::TextRun
- PDF::Reader::TransformationMatrix
- PDF::Reader::UnsupportedFeatureError
- PDF::Reader::WidthCalculator
- PDF::Reader::WidthCalculator::BuiltIn
- PDF::Reader::WidthCalculator::Composite
- PDF::Reader::WidthCalculator::TrueType
- PDF::Reader::WidthCalculator::TypeOneOrThree
- PDF::Reader::WidthCalculator::TypeZero
- PDF::Reader::XRef
- AFM
- AFM::Font

No matching classes.

# PDF::Reader::Parser

An internal PDF::Reader class that reads objects from the PDF file and converts them into useable ruby objects (hash's, arrays, true, false, etc)

### Constants

MAPPING
STRATEGIES
TOKEN_STRATEGY

### Public Class Methods

new(buffer, objects=nil) click to toggle source

Create a new parser around a PDF::Reader::Buffer object

buffer - a PDF::Reader::Buffer object that contains PDF data objects - a PDF::Reader::ObjectHash object that can return objects from the PDF file

    # File lib/pdf/reader/parser.rb, line 62
    def initialize (buffer, objects=nil)
      @buffer = buffer
      @objects  = objects
    end

### Public Instance Methods

object(id, gen) click to toggle source

Reads an entire PDF object from the buffer and returns it as a Ruby String. If the object is a content stream, returns both the stream and the dictionary that describes it

id - the object ID to return gen - the object revision number to return

    # File lib/pdf/reader/parser.rb, line 95
    def object (id, gen)
      Error.assert_equal(parse_token, id)
      Error.assert_equal(parse_token, gen)
      Error.str_assert(parse_token, "obj")

      obj = parse_token
      post_obj = parse_token

      if post_obj == "stream"
        stream(obj)
      else
        obj
      end
    end

parse_token(operators={}) click to toggle source

Reads the next token from the underlying buffer and convets it to an appropriate object

operators - a hash of supported operators to read from the underlying buffer.

    # File lib/pdf/reader/parser.rb, line 71
    def parse_token (operators={})
      token = @buffer.token

      if STRATEGIES.has_key? token
        STRATEGIES[token].call(self, token)
      elsif token.is_a? PDF::Reader::Reference
        token
      elsif operators.has_key? token
        Token.new(token)
      elsif token.respond_to?(:to_token)
        token.to_token
      elsif token =~ /\d*\.\d/
        token.to_f
      else
        token.to_i
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.