Last active
August 16, 2019 18:54
-
-
Save rush2sk8/dfbf73c45242f0d17e3194c411956abe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pdf-reader' | |
wordsToFind = ARGV | |
Dir.entries(".").select { |f| File.file?(File.join(".", f)) && File.extname(f) == ".pdf"}.each { |file| | |
puts file | |
pReader = PDF::Reader.new(file) | |
pReader.pages.each_with_index { |page, idx| | |
wordsToFind.each {|keyword| | |
if page.text.include? keyword | |
puts "pg: #{idx+1} has keyword: #{keyword}" | |
end | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
installation:
gem install pdf-reader
usage:
ruby searchpdfs.rb <keywords to find>
will spit out all instances of any of the keywords for any pdf in the same directory as this file.