Class: Pdfmult::PDFInfo

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

Overview

A class for PDF meta data (up to now only used for the page count).

Create an instance with PDFInfo.new, specifying the file name. PDFInfo tries to use the pdfinfo system tool to obtain meta data. If successful, the attribute page_count contains the page count, else the attribute is set to nil.

Constant Summary collapse

PDFINFOCMD =
'/usr/bin/pdfinfo'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, options = {}) ⇒ PDFInfo

This is the initialization method for the class.

file - file name of the PDF file



250
251
252
253
254
255
# File 'lib/pdfmult.rb', line 250

def initialize(file, options={})
  @file = file
  @binary = options[:pdfinfocmd] || PDFINFOCMD  # for unit tests
  @infos = retrieve_infos
  @page_count = @infos['Pages'] && @infos['Pages'].to_i
end

Instance Attribute Details

#page_countObject (readonly)

Returns the page count of the input file, or nil.



245
246
247
# File 'lib/pdfmult.rb', line 245

def page_count
  @page_count
end