Generate a UPC-E Barcode Image in Ruby
While the UPC-A barcode is the standard format used across North America, the UPC-E format can be helpful for specific situations as well. For example, if you work in retail and have simple products to encode, the UPC-E barcode could be ideal, as it is a compressed version of UPC-A that is not designed to convey complex information. To generate a UPC-E barcode image, you can use the following API in Ruby to instantly take care of the job for you.
Let’s start by adding the Ruby client to our Gemfile:
gem 'cloudmersive-barcode-api-client', '~> 2.0.3'
Once this is complete, we can call the function with the below code:
# load the gem
require 'cloudmersive-barcode-api-client'
# setup authorization
CloudmersiveBarcodeApiClient.configure do |config|
# Configure API key authorization: Apikey
config.api_key['Apikey'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['Apikey'] = 'Bearer'
endapi_instance = CloudmersiveBarcodeApiClient::GenerateBarcodeApi.newvalue = 'value_example' # String | UPC-E barcode value to generate frombegin
#Generate a UPC-E code barcode as PNG file
result = api_instance.generate_barcode_upce(value)
p result
rescue CloudmersiveBarcodeApiClient::ApiError => e
puts "Exception when calling GenerateBarcodeApi->generate_barcode_upce: #{e}"
end
This will promptly deliver a PNG file of your newly created barcode image. To retrieve your API key, visit the Cloudmersive website to register for a free account; this will provide 800 monthly calls across our multitude of APIs.