Class: CorpPdf::Fields::Text

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/corp_pdf/fields/text.rb

Overview

Handles text field creation

Instance Attribute Summary collapse

Attributes included from Base

#document, #field_type, #field_value, #metadata, #name, #options

Instance Method Summary collapse

Methods included from Base

#height, #initialize, #page_num, #width, #x, #y

Methods included from Actions::Base

#acroform_ref, #apply_patch, #find_page_by_number, #get_object_body_with_patch, #next_fresh_object_number, #patches, #resolver

Instance Attribute Details

#field_obj_numObject (readonly)

Returns the value of attribute field_obj_num.



9
10
11
# File 'lib/corp_pdf/fields/text.rb', line 9

def field_obj_num
  @field_obj_num
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/corp_pdf/fields/text.rb', line 11

def call
  @field_obj_num = next_fresh_object_number
  widget_obj_num = @field_obj_num + 1

  field_body = create_field_dictionary(@field_value, @field_type)
  page_ref = find_page_ref(page_num)

  widget_body = create_widget_annotation_with_parent(widget_obj_num, [@field_obj_num, 0], page_ref, x, y, width,
                                                     height, @field_type, @field_value)

  document.instance_variable_get(:@patches) << { ref: [@field_obj_num, 0], body: field_body }
  document.instance_variable_get(:@patches) << { ref: [widget_obj_num, 0], body: widget_body }

  add_field_to_acroform_with_defaults(@field_obj_num)
  add_widget_to_page(widget_obj_num, page_num)

  true
end