strzibny/invoice_printer
PDF
#!/usr/bin/env ruby
# This is an example of a international invoice with Czech labels
# and English translation.

require 'invoice_printer'

labels = {
  name: 'Faktura',
  provider: 'Prodejce',
  purchaser: 'Kupující',
  tax_id: 'IČ',
  tax_id2: 'DIČ',
  payment: 'Forma úhrady',
  payment_by_transfer: 'Platba na následující účet:',
  account_number: 'Číslo účtu',
  issue_date: 'Datum vydání',
  due_date: 'Datum splatnosti',
  item: 'Položka',
  quantity: 'Počet',
  unit: 'MJ',
  price_per_item: 'Cena za položku',
  amount: 'Celkem bez daně',
  subtotal: 'Cena bez daně',
  tax: 'DPH 21 %',
  total: 'Celkem'
}

# Default English labels as sublabels
sublabels = InvoicePrinter::PDFDocument::DEFAULT_LABELS
labels.merge!({ sublabels: sublabels })

first_item = InvoicePrinter::Document::Item.new(
  name: 'Konzultace',
  quantity: '2',
  unit: 'hod',
  price: 'Kč 500',
  amount: 'Kč 1.000'
)

second_item = InvoicePrinter::Document::Item.new(
  name: 'Programování',
  quantity: '10',
  unit: 'hod',
  price: 'Kč 900',
  amount: 'Kč 9.000'
)

invoice = InvoicePrinter::Document.new(
  number: 'č. 198900000001',
  provider_name: 'Petr Nový',
  provider_tax_id: '56565656',
  provider_street: 'Rolnická',
  provider_street_number: '1',
  provider_postcode: '747 05',
  provider_city: 'Opava',
  provider_city_part: 'Kateřinky',
  purchaser_name: 'Adam Černý',
  purchaser_street: 'Ostravská',
  purchaser_street_number: '1',
  purchaser_postcode: '747 70',
  purchaser_city: 'Opava',
  issue_date: '05/03/2016',
  due_date: '19/03/2016',
  subtotal: 'Kč 10.000',
  tax: 'Kč 2.100',
  total: 'Kč 12.100,-',
  bank_account_number: '156546546465',
  account_iban: 'IBAN464545645',
  account_swift: 'SWIFT5456',
  items: [first_item, second_item],
  note: 'Osoba je zapsána v živnostenském rejstříku.'
)

InvoicePrinter.print(
  document: invoice,
  labels: labels,
  font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
  logo: 'logo.png',
  file_name: 'promo.pdf'
)
    
A super simple and fast PDF invoicing in Ruby

Download

1.0.0

Install

$ gem install invoice_printer

Features

  • Invoice/document name and number
  • Purchaser and provider boxes with addresses and identificaton numbers
  • Payment method box showing banking details including SWIFT and IBAN fields
  • Issue/due dates box
  • Configurable items' table with item description, quantity, unit, price per unit, tax and item's total amount fields
  • Final subtotal/tax/total info box
  • Page numbers
  • Configurable labels
  • Configurable font file
  • Logotype (as image scaled to fit 50px of height)
  • Background (as image)
  • Stamp & signature (as image)
  • Note
  • Well tested

Contribute

Contributions welcome at strzibny/invoice_printer.

Authors

© Josef Strzibny