Class: Prawn::Fillform::Text

Inherits:
Field
  • Object
show all
Defined in:
lib/prawn-fillform.rb

Instance Method Summary collapse

Methods inherited from Field

#default_value, #description, #flags, #height, #initialize, #name, #rect, #value, #width, #x, #y

Constructor Details

This class inherits a constructor from Prawn::Fillform::Field

Instance Method Details

#alignObject



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/prawn-fillform.rb', line 63

def align
  case deref(@dictionary[:Q]).to_i
  when 0
    :left
  when 1
    :center
  when 2
    :right
  else
    :left
  end
end

#font_colorObject



99
100
101
102
# File 'lib/prawn-fillform.rb', line 99

def font_color
  return "0000" unless deref(@dictionary[:DA])
  Prawn::Graphics::Color.rgb2hex(deref(@dictionary[:DA]).split(" ")[3..5].collect { |e| e.to_f * 255 }).to_s
end

#font_sizeObject



80
81
82
83
# File 'lib/prawn-fillform.rb', line 80

def font_size
  return 12.0 unless deref(@dictionary[:DA])
  deref(@dictionary[:DA]).split(" ")[1].to_f
end

#font_styleObject



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/prawn-fillform.rb', line 85

def font_style
  return :normal unless deref(@dictionary[:DA])

  style = case deref(@dictionary[:DA]).split(" ")[0].split(",").last.to_s.downcase
  when "bold" then :bold
  when "italic" then :italic
  when "bold_italic" then :bold_italic
  when "normal" then :normal
  else
    :normal
  end
  style
end

#max_lengthObject



76
77
78
# File 'lib/prawn-fillform.rb', line 76

def max_length
  deref(@dictionary[:MaxLen]).to_i
end

#typeObject



104
105
106
# File 'lib/prawn-fillform.rb', line 104

def type
  :text
end