Class: NdrImport::AcroFormReader

Inherits:
PDF::Reader
  • Object
show all
Defined in:
lib/ndr_import/acroform_reader.rb

Overview

PDF AcroForm reader using the pdf-reader gem

Instance Method Summary collapse

Instance Method Details

#fields_hashObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ndr_import/acroform_reader.rb', line 6

def fields_hash
  fields = {}
  fields_from(acroform[:Fields]).each do |field|
    field_name = field[:T]
    unless field[:Subtype] == :Widget || field.key?(:Kids)
      raise "Widgets or Radio boxes expected, found a #{field[:Subtype].inspect}"
    end
    raise "Non-unique column name #{field_name}" if fields.key?(field_name)
    fields[field_name] = field[:V]
  end
  fields
end