diff options
Diffstat (limited to 'lib/pdf_form.rb')
-rw-r--r-- | lib/pdf_form.rb | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/lib/pdf_form.rb b/lib/pdf_form.rb index 9a831b3..a5af9ab 100644 --- a/lib/pdf_form.rb +++ b/lib/pdf_form.rb @@ -74,31 +74,24 @@ class PDFForm end def field(title, value) - next_line @document.text_box title, :at => [@document.bounds.left, @document.cursor], :width => label_width, :style => :bold - if value.class == String - @document.text_box value, - :at => [label_width, @document.cursor], - :width => @document.bounds.right - label_width, - :overflow => :expand - elsif value.class == Array - first = true - value.each do |v| - next_line unless first - - @document.text_box v.to_s, - :at => [label_width, @document.cursor], - :width => @document.bounds.right - label_width, - :overflow => :expand - - first = false + @document.span(@document.bounds.right - label_width, :position => label_width) do + if value.class == String + @document.text value + elsif value.class == Array + first = true + value.each do |v| + next_line unless first + @document.text v.to_s + first = false + end + elsif value.class == Float + @document.stroke { @document.horizontal_line label_width, label_width + value, :at => @document.cursor - one_line} end - elsif value.class == Float - @document.stroke { @document.horizontal_line label_width, label_width + value, :at => @document.cursor - one_line} end end |