Class: Spina::Shop::PackingSlipPdf
- Inherits:
-
Prawn::Document
- Object
- Prawn::Document
- Spina::Shop::PackingSlipPdf
- Defined in:
- app/pdfs/spina/shop/packing_slip_pdf.rb
Instance Method Summary collapse
- #header ⇒ Object
-
#initialize(order) ⇒ PackingSlipPdf
constructor
A new instance of PackingSlipPdf.
- #mr_hop ⇒ Object
- #order_details ⇒ Object
- #order_title ⇒ Object
Constructor Details
#initialize(order) ⇒ PackingSlipPdf
Returns a new instance of PackingSlipPdf.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/pdfs/spina/shop/packing_slip_pdf.rb', line 5 def initialize(order) super(page_size: "A4", margin: 15.mm, print_scaling: :none) @order = order # Base font size font_families.update( "Proxima Nova" => { normal: "#{Rails.root}/app/assets/fonts/proximanova-regular-webfont.ttf", semibold: "#{Rails.root}/app/assets/fonts/proximanova-semibold-webfont.ttf", bold: "#{Rails.root}/app/assets/fonts/proximanova-bold-webfont.ttf", italic: "#{Rails.root}/app/assets/fonts/proximanova-regitalic-webfont.ttf" }, "Icons" => { normal: "#{Rails.root}/app/assets/fonts/plango-next.ttf" } ) font "Proxima Nova" font_size 10 default_leading 3 mr_hop() header() order_title() order_details() end |
Instance Method Details
#header ⇒ Object
44 45 46 47 48 49 50 |
# File 'app/pdfs/spina/shop/packing_slip_pdf.rb', line 44 def header text "Pakbon", style: :semibold, size: 28 fill_color '999999' text "#{I18n.l @order.order_prepared_at, format: '%d %B %Y - %H:%M'}" fill_color '000000' move_down 5.cm end |
#mr_hop ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/pdfs/spina/shop/packing_slip_pdf.rb', line 31 def mr_hop float do indent(12.cm) do text "Mr Hop", style: :semibold, size: 14 text "Keizersveld 1" text "1234 AB, Venray" move_down 13 text "www.mrhop.nl" text "[email protected]" end end end |
#order_details ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/pdfs/spina/shop/packing_slip_pdf.rb', line 56 def order_details lines = [["Aantal", "Omschrijving", "Locatie", "Controle"]] @order.order_items.includes(:orderable).sort_by{|o| o.orderable.location}.each do |order_item| lines << ["#{order_item.quantity} x", order_item.description, order_item.orderable.location, ""] end table lines, header: true, column_widths: {0 => 2.cm, 1 => 10.cm}, width: bounds.width, cell_style: {borders: [:top], border_color: "DDDDDD", padding: 10} do |t| t.before_rendering_page do |page| page.row(0).border_top_width = 0 page.row(0).font_style = :bold page.row(1).border_top_width = 2 page.column(0).align = :right page.column(3).align = :right end end end |
#order_title ⇒ Object
52 53 54 |
# File 'app/pdfs/spina/shop/packing_slip_pdf.rb', line 52 def order_title text "Bestelling ##{@order.number}", style: :semibold, size: 18 end |