Remove spaces from searched text

PDF::Reader::PageTextReceiver removes spaces from runs.
https://github.com/yob/pdf-reader/blob/v2.9.1/lib/pdf/reader/page_text_receiver.rb#L141
The easy solution for now is to remove spaces from searched strings.
Another solution may be to create a custom PageTextReceiver to keep
spaces.
main
Guillaume Dott 2022-02-23 17:24:13 +01:00
parent d88002e45f
commit f43b536d0c
1 changed files with 2 additions and 0 deletions

View File

@ -6,6 +6,8 @@ require_relative "find_text/version"
module PDF::Reader::FindText
def find_text(text)
text = text.tr(' ', '')
runs(merge: false).each_cons(text.size).select do |r|
r.map(&:text).join == text
end.map do |r|