Sha256: 3eba14b382c7e2cc742c122370ea4d763f48390c055c4cb5e5d516e01866a813
Contents?: true
Size: 961 Bytes
Versions: 9
Compression:
Stored size: 961 Bytes
Contents
#!/usr/bin/env ruby require 'rubygems' $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../lib") USAGE = "USAGE: " + File.basename(__FILE__) + " <file> <object id> [generation]" require 'pdf/reader' filename, id, gen = *ARGV if filename.nil? || id.nil? puts USAGE exit 1 elsif !File.file?(filename) $stderr.puts "#{filename} does not exist" exit 1 end # tweak the users options id = id.to_i gen ||= 0 gen = gen.to_i # make magic happen begin obj = PDF::Reader.object_file(filename, id, gen) case obj when Hash, Array puts obj.inspect else puts obj end rescue PDF::Reader::InvalidObjectError $stderr.puts "Error retreiving object #{id}, gen #{gen}. Does it exist?" exit 1 rescue PDF::Reader::MalformedPDFError => e $stderr.puts "Malformed PDF file: #{e.message}" exit 1 rescue PDF::Reader::UnsupportedFeatureError => e $stderr.puts "PDF file implements a feature unsupported by PDF::Reader: #{e.message}" exit 1 end
Version data entries
9 entries across 9 versions & 1 rubygems