Ask Your Question
0

How can you create a GS1-128 barcode using Ruby on Rails?

asked 2022-01-15 11:00:00 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-11-22 04:00:00 +0000

nofretete gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-01-15 11:00:00 +0000

Seen: 8 times

Last updated: Nov 22 '21