Skip to content

Instantly share code, notes, and snippets.

@rush2sk8
Last active August 16, 2019 18:54
Show Gist options
  • Save rush2sk8/dfbf73c45242f0d17e3194c411956abe to your computer and use it in GitHub Desktop.
Save rush2sk8/dfbf73c45242f0d17e3194c411956abe to your computer and use it in GitHub Desktop.
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
}
}
}
@rush2sk8
Copy link
Author

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.

@PaoloLami
Copy link

gay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment