From e7aed5cfbd8ccf52303a739285dc8abebe8cebdf Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 31 Oct 2015 16:00:04 +0100 Subject: Fix flow of text that wraps to the next line in fields in the PDF --- lib/pdf_form.rb | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3