#!/usr/bin/env ruby $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib')) require 'pdf-reader' require 'optparse' def program_name File.basename(File.expand_path(__FILE__)) end OptionParser.new do |opts| opts.banner = "Usage: #{program_name} [options] file" opts.on('-h', '--help', 'Prints this help') do puts opts exit end end.parse! reader = PDF::Reader.new(ARGV[0]) reader.pages.each do |page| # written like this, and not file.write(page.text.split("\n")), # to behave in exactly the same way as the importer page.text.split("\n").each do |line| puts line end end