Class: Acrobat::Jso
- Inherits:
-
Object
- Object
- Acrobat::Jso
- Defined in:
- lib/acrobat/jso.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#ole_obj ⇒ Object
readonly
Returns the value of attribute ole_obj.
Instance Method Summary collapse
- #clear_form ⇒ Object
- #console ⇒ Object
- #export_as_fdf(name) ⇒ Object
- #field_count ⇒ Object
- #field_names ⇒ Object
- #fields_hash ⇒ Object
- #fill_form(hash) ⇒ Object
- #find_field(name_or_number) ⇒ Object
- #get_field(name) ⇒ Object
- #import_fdf(path) ⇒ Object
-
#initialize(doc, ole) ⇒ Jso
constructor
A new instance of Jso.
- #ole_get_field(field) ⇒ Object
-
#set_field(name, value) ⇒ Object
// Enumerate through all of the fields in the document.
- #show_console ⇒ Object
Constructor Details
#initialize(doc, ole) ⇒ Jso
Returns a new instance of Jso.
5 6 7 8 |
# File 'lib/acrobat/jso.rb', line 5 def initialize(doc, ole) @doc = doc @ole_obj = ole end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
3 4 5 |
# File 'lib/acrobat/jso.rb', line 3 def doc @doc end |
#ole_obj ⇒ Object (readonly)
Returns the value of attribute ole_obj.
3 4 5 |
# File 'lib/acrobat/jso.rb', line 3 def ole_obj @ole_obj end |
Instance Method Details
#clear_form ⇒ Object
76 77 78 |
# File 'lib/acrobat/jso.rb', line 76 def clear_form ole_obj.resetForm end |
#console ⇒ Object
23 24 25 |
# File 'lib/acrobat/jso.rb', line 23 def console @console ||= ole_obj.console end |
#export_as_fdf(name) ⇒ Object
40 41 |
# File 'lib/acrobat/jso.rb', line 40 def export_as_fdf(name) end |
#field_count ⇒ Object
72 73 74 |
# File 'lib/acrobat/jso.rb', line 72 def field_count ole_obj.numFields.to_int end |
#field_names ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/acrobat/jso.rb', line 31 def field_names result = [] count = field_count 0.upto(count - 1) do |i| result << ole_obj.getNthFieldName(i) end result end |
#fields_hash ⇒ Object
46 47 48 49 50 51 |
# File 'lib/acrobat/jso.rb', line 46 def fields_hash result = {} field_names.each_with_object(result) do |name, h| h[name] = get_field(name) end end |
#fill_form(hash) ⇒ Object
80 81 82 83 84 85 |
# File 'lib/acrobat/jso.rb', line 80 def fill_form(hash) clear_form hash.each do |k, v| set_field(k, v) end end |
#find_field(name_or_number) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/acrobat/jso.rb', line 10 def find_field(name_or_number) case name_or_number when String, Symbol ole_get_field(name_or_number.to_s) when Number ole_get_field(name_or_number) end end |
#get_field(name) ⇒ Object
67 68 69 70 |
# File 'lib/acrobat/jso.rb', line 67 def get_field(name) field = find_field(name) field&.Value end |
#import_fdf(path) ⇒ Object
43 44 |
# File 'lib/acrobat/jso.rb', line 43 def import_fdf(path) end |
#ole_get_field(field) ⇒ Object
19 20 21 |
# File 'lib/acrobat/jso.rb', line 19 def ole_get_field(field) ole_obj.getField(field) end |
#set_field(name, value) ⇒ Object
// Enumerate through all of the fields in the document. for (var i = 0; i < this.numFields; i++) console.println(“Field[” + i + “] = ” + this.getNthFieldName(i));
58 59 60 61 62 63 64 65 |
# File 'lib/acrobat/jso.rb', line 58 def set_field(name, value) field = find_field(name) field.Value = value.to_s if field rescue require "pry" binding.pry nil end |
#show_console ⇒ Object
27 28 29 |
# File 'lib/acrobat/jso.rb', line 27 def show_console console.show end |