Class: PdfForms::Pdf

Inherits:
Object
  • Object
show all
Includes:
SafePath
Defined in:
lib/pdf_forms/pdf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SafePath

#file_path, #normalize_path, #quote_path

Constructor Details

#initialize(path, pdftk, options = {}) ⇒ Pdf

Returns a new instance of Pdf.

Raises:

  • (IOError)


12
13
14
15
16
17
# File 'lib/pdf_forms/pdf.rb', line 12

def initialize(path, pdftk, options = {})
  @options = options
  @path = file_path(path)
  raise IOError unless File.readable?(@path)
  @pdftk = pdftk
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/pdf_forms/pdf.rb', line 10

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/pdf_forms/pdf.rb', line 10

def path
  @path
end

Instance Method Details

#field(name) ⇒ Object

the field object for the named field



28
29
30
# File 'lib/pdf_forms/pdf.rb', line 28

def field(name)
  fields.detect{ |f| f.name == name }
end

#fieldsObject

list of field objects for all defined fields

Initialize the object with utf8_fields: true to get utf8 encoded field names.



23
24
25
# File 'lib/pdf_forms/pdf.rb', line 23

def fields
  @fields ||= read_fields
end