Class: Stevedore::Pdf::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/stevedore/pdf.rb

Instance Method Summary collapse

Constructor Details

#initialize(pdf) ⇒ Metadata

Returns a new instance of Metadata.



23
24
25
26
27
28
29
30
31
# File 'lib/stevedore/pdf.rb', line 23

def initialize(pdf)
  @pdf = pdf
  output = Stevedore.run("pdfinfo #{@pdf.file_path}")
  @raw_metadata = output.split("\n").reduce(Hash.new) do |, line|
    name, val = line.split(/: +/,2)
    [name] = val
    
  end
end

Instance Method Details

#num_pagesObject



33
34
35
# File 'lib/stevedore/pdf.rb', line 33

def num_pages
  @raw_metadata["Pages"].to_i
end

#page_sizeObject



37
38
39
40
# File 'lib/stevedore/pdf.rb', line 37

def page_size
  size_data = @raw_metadata["Page size"].split(' ')
  [size_data[0].to_i, size_data[2].to_i]
end