Module: PDFRavager::FieldTypes::XFA
- Included in:
- PDFRavager::Fields::Checkbox, PDFRavager::Fields::Radio, PDFRavager::Fields::RichText, PDFRavager::Fields::Text
- Defined in:
- lib/pdf_ravager/field_types/xfa.rb
Instance Method Summary collapse
Instance Method Details
#set_xfa_value(node) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pdf_ravager/field_types/xfa.rb', line 19 def set_xfa_value(node) value_node = node.at_xpath("*[local-name()='value']") if value_node child_node = value_node.at_xpath("*[local-name()='#{xfa_node_type}']") if child_node # Complete node structure already exists - just set the value child_node.content = xfa_value else # Must create child <#{xfa_node_type}> node Nokogiri::XML::Builder.with(value_node) do |xml| xml.send("#{xfa_node_type}_", xfa_value) end end else # No <value> node exists - create whole structure Nokogiri::XML::Builder.with(node) do |xml| xml.value_ { xml.send("#{xfa_node_type}_", xfa_value) } end end end |
#xfa_name ⇒ Object
11 12 13 |
# File 'lib/pdf_ravager/field_types/xfa.rb', line 11 def xfa_name @name end |
#xfa_node_type ⇒ Object
7 8 9 |
# File 'lib/pdf_ravager/field_types/xfa.rb', line 7 def xfa_node_type 'text' end |
#xfa_value ⇒ Object
15 16 17 |
# File 'lib/pdf_ravager/field_types/xfa.rb', line 15 def xfa_value @value.to_s end |