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



257
258
259
260
261
262
# File 'lib/pdfmult.rb', line 257

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.



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

def page_count
  @page_count
end