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
parent
d88002e45f
commit
f43b536d0c
|
@ -6,6 +6,8 @@ require_relative "find_text/version"
|
||||||
|
|
||||||
module PDF::Reader::FindText
|
module PDF::Reader::FindText
|
||||||
def find_text(text)
|
def find_text(text)
|
||||||
|
text = text.tr(' ', '')
|
||||||
|
|
||||||
runs(merge: false).each_cons(text.size).select do |r|
|
runs(merge: false).each_cons(text.size).select do |r|
|
||||||
r.map(&:text).join == text
|
r.map(&:text).join == text
|
||||||
end.map do |r|
|
end.map do |r|
|
||||||
|
|
Loading…
Reference in New Issue