class Origami::PDF::JavaScript::Field

Public Class Methods

new(engine, field) click to toggle source
# File lib/origami/javascript.rb, line 481
def initialize(engine, field)
    super(engine)

    @field = field
end

Public Instance Methods

doc() click to toggle source
# File lib/origami/javascript.rb, line 487
def doc; Doc.new(@field.document) end
name() click to toggle source
# File lib/origami/javascript.rb, line 488
def name
    (@field.T.value if @field.has_key?(:T)).to_s
end
type() click to toggle source
# File lib/origami/javascript.rb, line 500
def type
    return '' unless @field.key?(:FT)

    type_name =
    case @field.FT.value
    when PDF::Field::Type::BUTTON
        button_type

    when PDF::Field::Type::TEXT then 'text'
    when PDF::Field::Type::SIGNATURE then 'signature'
    when PDF::Field::Type::CHOICE
        choice_type
    end

    type_name.to_s
end
value() click to toggle source
# File lib/origami/javascript.rb, line 492
def value
    @field.V.value if @field.has_key?(:V)
end
valueAsString() click to toggle source
# File lib/origami/javascript.rb, line 496
def valueAsString
    self.value.to_s
end

Private Instance Methods

button_type() click to toggle source
# File lib/origami/javascript.rb, line 519
def button_type
    return if @field.key?(:Ff) and not @field.Ff.is_a?(Integer)

    flags = @field.Ff.to_i
    
   if (flags & Annotation::Widget::Button::Flags::PUSHBUTTON) != 0
       'button'
   elsif (flags & Annotation::Widget::Button::Flags::RADIO) != 0
       'radiobox'
   else
       'checkbox'
   end
end
choice_type() click to toggle source
# File lib/origami/javascript.rb, line 533
def choice_type
    return if @field.key?(:Ff) and not @field.Ff.is_a?(Integer)

    if (@field.Ff.to_i & Annotation::Widget::Choice::Flags::COMBO) != 0
        'combobox'
    else
        'listbox'
    end
end