pdf-reader
pdf-reader copied to clipboard
Would the author be interested in a text_at page function?
I did this very basic function for getting text at certain coordinates:
def text_at(page, x1, y1, x2, y2)
text = String.new
page.runs.each do |r|
next unless r.x >= x1 && r.y >= y1 && r.endx <= x2 && r.endy <= y2
text << r.text
end
text
end
Probably it would be nice to have it on the library itself.
#411 (shipped in 2.8.0) made the following possible:
PDF::Reader.open("somefile.pdf") do |pdf|
puts reader.page(1).text(rect: PDF::Reader::Rectangle.new(0, 0, 100, 100))
end
Does that meet a similar need?
It does. I couldn't find the available opts on the API docs, is that documented anywhere?