Class: PDF::Inspector::Text
- Inherits:
-
PDF::Inspector
- Object
- PDF::Inspector
- PDF::Inspector::Text
- Defined in:
- lib/pdf/inspector/text.rb
Instance Attribute Summary collapse
-
#character_spacing ⇒ Object
Returns the value of attribute character_spacing.
-
#font_settings ⇒ Object
Returns the value of attribute font_settings.
-
#kerned ⇒ Object
Returns the value of attribute kerned.
-
#positions ⇒ Object
Returns the value of attribute positions.
-
#size ⇒ Object
Returns the value of attribute size.
-
#strings ⇒ Object
Returns the value of attribute strings.
-
#text_rendering_mode ⇒ Object
Returns the value of attribute text_rendering_mode.
-
#word_spacing ⇒ Object
Returns the value of attribute word_spacing.
Instance Method Summary collapse
-
#initialize ⇒ Text
constructor
A new instance of Text.
- #move_text_position(tx, ty) ⇒ Object
- #page=(page) ⇒ Object
- #set_character_spacing(*params) ⇒ Object
- #set_text_font_and_size(*params) ⇒ Object
- #set_text_rendering_mode(*params) ⇒ Object
- #set_word_spacing(*params) ⇒ Object
- #show_text(*params) ⇒ Object
- #show_text_with_positioning(*params) ⇒ Object
Methods inherited from PDF::Inspector
Constructor Details
#initialize ⇒ Text
Returns a new instance of Text.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/pdf/inspector/text.rb', line 8 def initialize @font_settings = [] @fonts = {} @font_objects = {} @strings = [] @character_spacing = [] @word_spacing = [] @kerned = [] @text_rendering_mode = [] @positions = [] end |
Instance Attribute Details
#character_spacing ⇒ Object
Returns the value of attribute character_spacing.
5 6 7 |
# File 'lib/pdf/inspector/text.rb', line 5 def character_spacing @character_spacing end |
#font_settings ⇒ Object
Returns the value of attribute font_settings.
4 5 6 |
# File 'lib/pdf/inspector/text.rb', line 4 def font_settings @font_settings end |
#kerned ⇒ Object
Returns the value of attribute kerned.
6 7 8 |
# File 'lib/pdf/inspector/text.rb', line 6 def kerned @kerned end |
#positions ⇒ Object
Returns the value of attribute positions.
6 7 8 |
# File 'lib/pdf/inspector/text.rb', line 6 def positions @positions end |
#size ⇒ Object
Returns the value of attribute size.
4 5 6 |
# File 'lib/pdf/inspector/text.rb', line 4 def size @size end |
#strings ⇒ Object
Returns the value of attribute strings.
4 5 6 |
# File 'lib/pdf/inspector/text.rb', line 4 def strings @strings end |
#text_rendering_mode ⇒ Object
Returns the value of attribute text_rendering_mode.
6 7 8 |
# File 'lib/pdf/inspector/text.rb', line 6 def text_rendering_mode @text_rendering_mode end |
#word_spacing ⇒ Object
Returns the value of attribute word_spacing.
5 6 7 |
# File 'lib/pdf/inspector/text.rb', line 5 def word_spacing @word_spacing end |
Instance Method Details
#move_text_position(tx, ty) ⇒ Object
33 34 35 |
# File 'lib/pdf/inspector/text.rb', line 33 def move_text_position(tx, ty) @positions << [tx, ty] end |
#page=(page) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/pdf/inspector/text.rb', line 20 def page=(page) @state = PDF::Reader::PageState.new(page) page.fonts.each do |label, stream| @fonts[label] = stream[:BaseFont] @font_objects[label] = PDF::Reader::Font.new(page.objects, stream) end end |
#set_character_spacing(*params) ⇒ Object
55 56 57 58 |
# File 'lib/pdf/inspector/text.rb', line 55 def set_character_spacing(*params) @state.set_character_spacing(*params) @character_spacing << params[0] end |
#set_text_font_and_size(*params) ⇒ Object
28 29 30 31 |
# File 'lib/pdf/inspector/text.rb', line 28 def set_text_font_and_size(*params) @state.set_text_font_and_size(*params) @font_settings << { :name => @fonts[params[0]], :size => params[1] } end |
#set_text_rendering_mode(*params) ⇒ Object
50 51 52 53 |
# File 'lib/pdf/inspector/text.rb', line 50 def set_text_rendering_mode(*params) @state.set_text_rendering_mode(*params) @text_rendering_mode << params[0] end |
#set_word_spacing(*params) ⇒ Object
60 61 62 63 |
# File 'lib/pdf/inspector/text.rb', line 60 def set_word_spacing(*params) @state.set_word_spacing(*params) @word_spacing << params[0] end |
#show_text(*params) ⇒ Object
37 38 39 40 |
# File 'lib/pdf/inspector/text.rb', line 37 def show_text(*params) @kerned << false @strings << @state.current_font.to_utf8(params[0]) end |
#show_text_with_positioning(*params) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/pdf/inspector/text.rb', line 42 def show_text_with_positioning(*params) @kerned << true # ignore kerning information show_text params[0].reject { |e| Numeric === e }.join end |