Method: PDF::Reader::TextRun#intersection_area_percent

Defined in:
lib/pdf/reader/text_run.rb

#intersection_area_percent(other_run) ⇒ Object

return what percentage of this text run is overlapped by another run



81
82
83
84
85
86
87
88
89
# File 'lib/pdf/reader/text_run.rb', line 81

def intersection_area_percent(other_run)
  return 0 unless intersect?(other_run)

  dx = [endx, other_run.endx].min - [x, other_run.x].max
  dy = [endy, other_run.endy].min - [y, other_run.y].max
  intersection_area = dx*dy

  intersection_area.to_f / area
end