diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2015-10-31 16:00:04 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2015-10-31 16:51:02 +0100 |
commit | e7aed5cfbd8ccf52303a739285dc8abebe8cebdf (patch) | |
tree | 5264e43fce98ac44aaaf250c74d6e4fe19501523 | |
parent | 913629206e8d89dd641a6bfcfb143fc7da7c549c (diff) | |
download | norsk-urskog-registrations-e7aed5cfbd8ccf52303a739285dc8abebe8cebdf.tar.gz norsk-urskog-registrations-e7aed5cfbd8ccf52303a739285dc8abebe8cebdf.tar.bz2 norsk-urskog-registrations-e7aed5cfbd8ccf52303a739285dc8abebe8cebdf.zip |
Fix flow of text that wraps to the next line in fields in the PDF
-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 |