Class: PDF::Reader::PageTextReceiver
- Inherits:
-
Object
- Object
- PDF::Reader::PageTextReceiver
- Extended by:
- Forwardable
- Defined in:
- lib/pdf/reader/page_text_receiver.rb
Instance Method Summary collapse
- #content ⇒ Object
-
#invoke_xobject(label) ⇒ Object
XObjects.
-
#move_to_next_line_and_show_text(str) ⇒ Object
‘.
-
#page=(page) ⇒ Object
starting a new page.
-
#set_spacing_next_line_show_text(aw, ac, string) ⇒ Object
“.
-
#show_text(string) ⇒ Object
record text that is drawn on the page.
-
#show_text_with_positioning(params) ⇒ Object
TJ.
Instance Method Details
#content ⇒ Object
36 37 38 39 40 41 |
# File 'lib/pdf/reader/page_text_receiver.rb', line 36 def content keys = @content.keys.sort.reverse keys.map { |key| @content[key] }.join("\n") end |
#invoke_xobject(label) ⇒ Object
XObjects
80 81 82 83 84 85 86 87 |
# File 'lib/pdf/reader/page_text_receiver.rb', line 80 def invoke_xobject(label) @state.invoke_xobject(label) do |xobj| case xobj when PDF::Reader::FormXObject then xobj.walk(self) end end end |
#move_to_next_line_and_show_text(str) ⇒ Object
‘
66 67 68 69 |
# File 'lib/pdf/reader/page_text_receiver.rb', line 66 def move_to_next_line_and_show_text(str) # ' @state.move_to_start_of_next_line show_text(str) end |
#page=(page) ⇒ Object
starting a new page
31 32 33 34 |
# File 'lib/pdf/reader/page_text_receiver.rb', line 31 def page=(page) @state = PageState.new(page) @content = {} end |
#set_spacing_next_line_show_text(aw, ac, string) ⇒ Object
“
71 72 73 74 75 |
# File 'lib/pdf/reader/page_text_receiver.rb', line 71 def set_spacing_next_line_show_text(aw, ac, string) # " @state.set_word_spacing(aw) @state.set_character_spacing(ac) move_to_next_line_and_show_text(string) end |
#show_text(string) ⇒ Object
record text that is drawn on the page
48 49 50 51 52 53 |
# File 'lib/pdf/reader/page_text_receiver.rb', line 48 def show_text(string) # Tj raise PDF::Reader::MalformedPDFError, "current font is invalid" if @state.current_font.nil? newx, newy = @state.trm_transform(0,0) @content[newy] ||= "" @content[newy] << @state.current_font.to_utf8(string) end |
#show_text_with_positioning(params) ⇒ Object
TJ
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/pdf/reader/page_text_receiver.rb', line 55 def show_text_with_positioning(params) # TJ params.each { |arg| case arg when String show_text(arg) when Fixnum, Float show_text(" ") if arg > 1000 end } end |