class PdfForms::Pdf
Attributes
options[R]
path[R]
Public Class Methods
new(path, pdftk, options = {})
click to toggle source
# File lib/pdf_forms/pdf.rb, line 11 def initialize(path, pdftk, options = {}) @options = options @path = normalize_path(path) raise IOError unless File.readable?(@path) @pdftk = pdftk end
Public Instance Methods
field(name)
click to toggle source
the field object for the named field
# File lib/pdf_forms/pdf.rb, line 27 def field(name) fields.detect{ |f| f.name == name } end
fields()
click to toggle source
list of field objects for all defined fields
Initialize the object with utf8_fields: true to get utf8 encoded field names.
# File lib/pdf_forms/pdf.rb, line 22 def fields @fields ||= read_fields end
Private Instance Methods
read_fields()
click to toggle source
# File lib/pdf_forms/pdf.rb, line 33 def read_fields dump_method = options[:utf8_fields] ? 'dump_data_fields_utf8' : 'dump_data_fields' field_output = @pdftk.call_pdftk path, dump_method @fields = field_output.split(/^---\n/).map do |field_text| Field.new field_text if field_text =~ /FieldName:/ end.compact end