Class: PDF::Inspector

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/inspector.rb,
lib/pdf/inspector/page.rb,
lib/pdf/inspector/text.rb,
lib/pdf/inspector/xobject.rb,
lib/pdf/inspector/graphics.rb,
lib/pdf/inspector/extgstate.rb

Defined Under Namespace

Modules: Graphics Classes: ExtGState, Page, Text, XObject

Class Method Summary collapse

Class Method Details

.analyze(output, *args, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pdf/inspector.rb', line 12

def self.analyze(output,*args,&block) 
  if output.is_a?(String)
    output = StringIO.new(output)
  end
  obs = self.new(*args, &block)
  PDF::Reader.open(output) do |reader|
    reader.pages.each do |page|
      page.walk(obs)
    end
  end
  obs  
end

.analyze_file(filename, *args, &block) ⇒ Object



25
26
27
28
29
# File 'lib/pdf/inspector.rb', line 25

def self.analyze_file(filename,*args,&block)
  File.open(filename, "rb") do |io|
    analyze(io, *args,&block)
  end
end

.parse(obj) ⇒ Object



31
32
33
34
# File 'lib/pdf/inspector.rb', line 31

def self.parse(obj)
  PDF::Reader::Parser.new(
    PDF::Reader::Buffer.new(StringIO.new(obj)), nil).parse_token
end