Class: PDF::Inspector::Page

Inherits:
PDF::Inspector show all
Extended by:
Forwardable
Defined in:
lib/pdf/inspector/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PDF::Inspector

analyze, analyze_file, parse

Constructor Details

#initializePage

Returns a new instance of Page


12
13
14
# File 'lib/pdf/inspector/page.rb', line 12

def initialize
  @pages = []
end

Instance Attribute Details

#pagesObject (readonly)

Returns the value of attribute pages


8
9
10
# File 'lib/pdf/inspector/page.rb', line 8

def pages
  @pages
end

Instance Method Details

#page=(page) ⇒ Object


16
17
18
19
# File 'lib/pdf/inspector/page.rb', line 16

def page=(page)
  @pages << { size: page.attributes[:MediaBox][-2..-1], strings: [] }
  @state = PDF::Reader::PageState.new(page)
end

#show_text(*params) ⇒ Object


21
22
23
24
25
# File 'lib/pdf/inspector/page.rb', line 21

def show_text(*params)
  params.each do |param|
    @pages.last[:strings] << @state.current_font.to_utf8(param)
  end
end

#show_text_with_positioning(*params) ⇒ Object


27
28
29
30
31
32
# File 'lib/pdf/inspector/page.rb', line 27

def show_text_with_positioning(*params)
  # ignore kerning information
  show_text params[0].reject { |e|
    e.is_a? Numeric
  }.join
end