Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here are the steps to create a GS1-128 barcode using Ruby on Rails:

  1. Install the barby and barby-ean-ucc gems in your Rails application.

    gem install barby
    gem install barby-ean-ucc
    
  2. Create a new barcode object using the Barby::EAN128 class.

    barcode = Barby::EAN128.new('01012345678901234567890')
    
  3. Render the barcode using a renderer. In this example, we'll use the Barby::PngOutputter to output the barcode as a PNG image.

    png_data = Barby::PngOutputter.new(barcode).to_png
    
  4. Optionally, you can save the barcode image to a file.

    File.open('barcode.png', 'wb') { |f| f.write png_data }
    

That's it! You now have a GS1-128 barcode generated in Ruby on Rails.