Module: Prawn::Forms

Defined in:
lib/prawn/forms.rb

Instance Method Summary collapse

Instance Method Details

#button(text) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/prawn/forms.rb', line 12

def button(text)
  add_interactive_field(:Btn, :T => Prawn::Core::LiteralString.new(text),
                              :DA => Prawn::Core::LiteralString.new("/Helv 0 Tf 0 g"),
                              :F => 4,
                              :Ff => 65536,
                              :MK => {:CA => Prawn::Core::LiteralString.new(text), :BG => [0.75294, 0.75294, 0.75294], :BC => [0.75294, 0.75294, 0.75294]},
                              :Rect => [304.5, 537.39, 429, 552.39])

end

#text_field(name, x, y, w, h, opts = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/prawn/forms.rb', line 22

def text_field(name, x, y, w, h, opts = {})
  x, y = map_to_absolute(x, y)

  field_dict = {:T => Prawn::Core::LiteralString.new(name),
                :DA => Prawn::Core::LiteralString.new("/Helv 0 Tf 0 g"),
                :F => 4,
                :Ff => flags_from_options(opts),
                :BS => {:Type => :Border, :W => 1, :S => :S},
                :MK => {:BC => [0, 0, 0]},
                :Rect => [x, y, x + w, y - h]}

  if opts[:default]
    field_dict[:V] = Prawn::Core::LiteralString.new(opts[:default])
  end

  add_interactive_field(:Tx, field_dict)
end