# Band registration form for Norsk Urskog Metal Sampler # Copyright (C) 2015-2018 Harald Eilersen # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . require 'prawn' require 'prawn/measurement_extensions' Prawn::Font::AFM.hide_m17n_warning = true class PDFForm def initialize(band) @band = band @document = Prawn::Document.new(:page_size => "A4") end def render(filename) heading intro_text @document.pad_bottom(5) do subheading("Generell info:") field("Band:", @band.name_and_city) field("Webside:", @band.website) field("Plateselskap:", @band.label) field("Kort bio:", @band.short_bio) field("Medlemmer:", @band.members) end @document.pad_bottom(5) do field("Kontaktperson:", @band.contact.name) field("Postadresse:", @band.contact.addr) field("Telefon:", @band.contact.phone) field("Epost:", @band.contact.email) end subheading("Låter:") @band.songs.each do |song| unless song.title.empty? @document.pad_bottom(10) do field("Tittel", song.to_s) field("ISRC-kode:", song.isrc) field("Utøvere:", song.performers) field("Komponister:", song.composers) field("Merknad:", song.notes) end end end if @document.cursor < 120 @document.start_new_page end subheading("Fullmakt:") end_text @document.number_pages "#{@band.name} - Norsk Urskog 2019 - Side ", :align => :center, :at => [0, 0] @document.render_file filename end private def one_line @one_line ||= @document.font_size.inspect.to_f * 1.4 end def label_width 3.2.cm end def heading @document.pad_bottom(10) do @document.text "Påmelding til Norsk Urskog 2019", :size => 20 end end def subheading(text) @document.pad(5) do @document.text text, :size => 16, :style => :bold end end def next_line @document.move_down one_line end def field(title, value) @document.pad_bottom(2) do @document.text_box(title, :at => [@document.bounds.left, @document.cursor], :width => label_width, :style => :bold) @document.span(@document.bounds.right - label_width, :position => label_width) do if value.class == String value = " " if value.empty? @document.text value elsif value.class == Array first = true value.each do |v| @document.text v.to_s end elsif value.class == Float @document.stroke { @document.horizontal_line 0, value, :at => @document.cursor - one_line} end end end end def intro_text @document.pad_bottom(10) do @document.text((<<-END.gsub(/\s+/, ' ')), :inline_format => true) Takk for din påmelding til Norsk Urskog 2019! Nedenfor finner du de opplysningene vi har registrert om din påmelding. Vennligst se over at alt er riktig, skriv så ut og send skjemaet i underskrevet tilstand tilbake til:

Norsk Urskog
v/Harald Eilertsen
Grettevegen 9
3622 Svene END end end def end_text @document.span(@document.bounds.right) do @document.pad(5) do @document.text((<<-END.gsub(/\s+/, ' ') + "\n\n"), :inline_format => true) Jeg bekrefter herved at informasjonen gitt ovenfor er riktig, og at jeg på vegne av #{@band.name} har fullmakt til å melde ovennevnte låter på Norsk Urskog Metal Sampler 2019: END end @document.pad_bottom(32) { field("Dato/Sted:", 10.cm) } @document.pad_bottom(32) { field("Sign:", 10.cm) } field("Leselig navn:", 10.cm) end end end