class PDF::Reader::PositionalTextReceiver
Receiver to access positional (x,y) text content from a PDF
Typical usage:
reader = PDF::Reader.new(filename) receiver = PDF::Reader::PositionalTextReceiver.new reader.page(page).walk(receiver) receiver.content
Public Instance Methods
content()
click to toggle source
override PageTextReceiver content accessor . Returns a hash of positional text:
{ y_coord=>{x_coord=>text, x_coord=>text }, y_coord=>{x_coord=>text, x_coord=>text } }
# File lib/pdf/reader/positional_text_receiver.rb, line 27 def content @content end
show_text(string)
click to toggle source
record text that is drawn on the page
# File lib/pdf/reader/positional_text_receiver.rb, line 13 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][newx] ||= '' @content[newy][newx] << @state.current_font.to_utf8(string) end