From b04e6f3d6dd3ec5ed2d47f700c9e62f7da5efd32 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 4 Oct 2015 16:07:19 +0200 Subject: Make arrays render nicer in PDF, and tread contact address as array --- lib/pdf_form.rb | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/pdf_form.rb b/lib/pdf_form.rb index 7d0aa93..57db881 100644 --- a/lib/pdf_form.rb +++ b/lib/pdf_form.rb @@ -18,8 +18,7 @@ class PDFForm next_line field("Kontaktperson:", @band.contact.name) - field("Postadresse:", @band.contact.addr) - next_line + field("Postadresse:", @band.contact.addr.split("\n")) field("Telefon:", @band.contact.phone) field("Epost:", @band.contact.email) @@ -51,18 +50,27 @@ class PDFForm def field(title, value) next_line - y_pos = @document.cursor - @document.text_box title, :at => [@document.bounds.left, y_pos], :width => label_width, :style => :bold + @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, y_pos], :width => @document.bounds.right - label_width + @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| - @document.text_box v.to_s, :at => [label_width, y_pos], :width => @document.bounds.right - label_width - y_pos -= one_line - next_line - end - end + 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 + end end end -- cgit v1.2.3