Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hidakatsuya/2007493 to your computer and use it in GitHub Desktop.

Select an option

Save hidakatsuya/2007493 to your computer and use it in GitHub Desktop.
Create a bar code using Ghostscript
# coding: utf-8
require 'rghost'
require 'rghost_barcode'
require 'thinreports'
RGhost::Config::GS[:path] = '/usr/local/bin/gs'
bar = RGhost::Document.new :paper => ['10 cm', '1 cm']
bar.barcode_japanpost '26300233-30-8-403',
:x => 0, :y => 0, :width => '10 cm', :height => '1 cm'
bar_io = StringIO.new(bar.render_stream(:png))
report = ThinReports::Report.new :layout => 'rghost'
report.start_new_page do |page|
page.item(:barcode).src(bar_io)
end
report.generate_file 'rghost.pdf'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment