Class: Origami::PDF::LinearParser

Inherits:
Parser show all
Defined in:
lib/origami/parsers/pdf/linear.rb

Overview

Create a new PDF linear Parser.

Constant Summary

Constants inherited from Origami::Parser

Origami::Parser::VERBOSE_DEBUG, Origami::Parser::VERBOSE_INFO, Origami::Parser::VERBOSE_QUIET, Origami::Parser::VERBOSE_TRACE

Instance Attribute Summary

Attributes inherited from Origami::Parser

#options

Instance Method Summary collapse

Methods inherited from Parser

#initialize

Methods inherited from Origami::Parser

#debug, #defer_type_cast, #error, #info, init_scanner, #initialize, #parse_object, #parse_trailer, #parse_xreftable, #pos, #pos=, #target_data, #target_filename, #target_filesize, #trace, #warn

Constructor Details

This class inherits a constructor from Origami::PDF::Parser

Instance Method Details

#parse(stream) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/origami/parsers/pdf/linear.rb', line 29

def parse(stream)
  super

  pdf = parse_initialize

  #
  # Parse each revision
  #
  revision = 0
  until @data.eos?
    begin
      pdf.add_new_revision unless revision.zero?

      parse_revision(pdf, revision)
      revision += 1
    rescue
      error "Cannot read : " + (@data.peek(10) + "...").inspect
      error "Stopped on exception : " + $!.message
      warn $!.backtrace.join($/)

      break
    end
  end

  pdf.loaded!

  parse_finalize(pdf)
end