Sha256: 6ab7a29f5779fc36d3ee3249a0d0f767c0942f69f4a74cb296b747402c34b3ba

Contents?: true

Size: 1.08 KB

Versions: 22

Compression:

Stored size: 1.08 KB

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 = nil
  PDF::Reader.open(filename) do |pdf|
    obj = pdf.objects[PDF::Reader::Reference.new(id, gen)]
  end

  case obj
  when Hash, Array
    puts obj.inspect
  when PDF::Reader::Stream
    puts obj.hash.inspect
    puts obj.unfiltered_data
  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

22 entries across 21 versions & 2 rubygems

Version Path
pdf-reader-2.13.0 bin/pdf_object
pdf-reader-2.12.0 bin/pdf_object
pdf-reader-2.11.0 bin/pdf_object
pdf-reader-2.10.0 bin/pdf_object
pdf-reader-2.9.2 bin/pdf_object
pdf-reader-2.9.1 bin/pdf_object
pdf-reader-2.9.0 bin/pdf_object
pdf-reader-2.8.0 bin/pdf_object
pdf-reader-2.7.0 bin/pdf_object
pdf-reader-2.6.0 bin/pdf_object
pdf-reader-2.5.0 bin/pdf_object
pdf-reader-2.4.2 bin/pdf_object
pdf-reader-2.4.1 bin/pdf_object
pdf-reader-2.4.0 bin/pdf_object
pdf-reader-2.3.0 bin/pdf_object
pdf-reader-2.2.1 bin/pdf_object
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.4.0/gems/pdf-reader-2.2.0/bin/pdf_object
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.5.0/gems/pdf-reader-2.2.0/bin/pdf_object
pdf-reader-2.2.0 bin/pdf_object
pdf-reader-2.1.0 bin/pdf_object