Sha256: 0a2e4fa58e22449f40513097085618b9340341cf248f80ac92c1bc8fcd9bb76b
Contents?: true
Size: 941 Bytes
Versions: 3
Compression:
Stored size: 941 Bytes
Contents
#!/usr/bin/env ruby $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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pdf-reader-0.7.3 | bin/pdf_object |
pdf-reader-0.7.4 | bin/pdf_object |
pdf-reader-0.7.5 | bin/pdf_object |