Method: PDF::Reader::Turtletext::Textangle#text

Defined in:
lib/pdf/reader/turtletext/textangle.rb

#textObject

Returns the text array found within the defined region. Each line of text is an array of the seperate text elements found on that line.

[["first line first text", "first line last text"],["second line text"]]


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/pdf/reader/turtletext/textangle.rb', line 93

def text
  return unless reader

  xmin = if right_of
    if [Fixnum,Float].include?(right_of.class)
      right_of
    elsif xy = reader.text_position(right_of,page)
      xy[:x]
    end
  else
    0
  end
  xmax = if left_of
    if [Fixnum,Float].include?(left_of.class)
      left_of
    elsif xy = reader.text_position(left_of,page)
      xy[:x]
    end
  else
    99999 # TODO: figure out the actual limit?
  end

  ymin = if above
    if [Fixnum,Float].include?(above.class)
      above
    elsif xy = reader.text_position(above,page)
      xy[:y]
    end
  else
    0
  end
  ymax = if below
    if [Fixnum,Float].include?(below.class)
      below
    elsif xy = reader.text_position(below,page)
      xy[:y]
    end
  else
    99999 # TODO: figure out the actual limit?
  end

  reader.text_in_region(xmin,xmax,ymin,ymax,page,inclusive)
end