summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2015-10-04 16:07:19 +0200
committerHarald Eilertsen <haraldei@anduin.net>2015-10-04 16:07:19 +0200
commitb04e6f3d6dd3ec5ed2d47f700c9e62f7da5efd32 (patch)
tree4b1487f5c4a2e706f34aea3643b772129582f70c /lib
parentd1c061f1aee62c83e21fb5bf7b26901ab8c12af4 (diff)
downloadnorsk-urskog-registrations-b04e6f3d6dd3ec5ed2d47f700c9e62f7da5efd32.tar.gz
norsk-urskog-registrations-b04e6f3d6dd3ec5ed2d47f700c9e62f7da5efd32.tar.bz2
norsk-urskog-registrations-b04e6f3d6dd3ec5ed2d47f700c9e62f7da5efd32.zip
Make arrays render nicer in PDF, and tread contact address as array
Diffstat (limited to 'lib')
-rw-r--r--lib/pdf_form.rb28
1 files changed, 18 insertions, 10 deletions
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