Ruby library for printing using ESC/POS (thermal) printers using CUPS.
Add the following line to Gemfile:
gem 'pos-printer'
and run bundle install
from your shell.
To install the gem manually from your shell, run:
gem install pos-printer
require 'pos-printer'
POS::Printer.print('my-printer-name-on-cups') do |p|
p.align_center
p.print_logo
p.big_font
p.text 'MY HEADER'
p.align_left
p.small_font
p.text 'some body'
end
You may also specify extra options to pass to lp
:
require 'pos-printer'
POS::Printer.print('my-printer-name-on-cups', lp_options: ['-h', 'somehost:port']) do |p|
# Your printing code
end