Ask Your Question
0

How can I create a barcode in Ruby on Rails with GS1 128 format?

asked 2021-10-25 11:00:00 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-10-21 10:00:00 +0000

pufferfish gravatar image

One way to create a GS1 128 barcode in Ruby on Rails is by using the "barby" gem. Here's an example code snippet to generate a GS1 128 barcode with the "barby" gem:

require 'barby/barcode/gs1_128'
require 'barby/outputter/png_outputter'

# Create the barcode object
barcode = Barby::GS1128.new('01012345678901234567')

# Set the application identifier for the barcode
barcode.application_identifier = '01'

# Generate the barcode image
png = Barby::PngOutputter.new(barcode).to_png

# Save the barcode image to a file
File.open('gs1_128.png', 'wb') { |f| f.write png }

In the above example, we create a new Barby::GS1128 barcode object with a sample data value of "01012345678901234567". We then set the application identifier to "01" to indicate that this is a GS1 128 barcode with a Global Trade Item Number (GTIN). Finally, we generate a PNG image of the barcode and save it to a file named "gs1_128.png".

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: 2021-10-25 11:00:00 +0000

Seen: 10 times

Last updated: Oct 21 '21